我创建了一个DLL,入口函数是DllEntryPoint  
 
但是我在调用的时候却发现我在DllEntryPoint里做的初始化并没有被运行,后来跟踪到DLL里却发现DllEntryPoint并没有在LOADLIBRARY的时运行,不知道为什么?  
 
哪位大哥能解释一下

解决方案 »

  1.   

    If the module is a DLL not already mapped for the calling process, the system calls the DLL's DllMain function with the DLL_PROCESS_ATTACH value. If the DLL's entry-point function does not return TRUE, LoadLibrary fails and returns NULL. (The system immediately calls your entry-point function with DLL_PROCESS_DETACH and unloads the DLL.) 
      

  2.   

    我在程序增加DLLMain函数会提示我已经有一个DLLMain存在了,是系统默认增加的,我不知道该如何去在DLLMain里增加。还有,DllEntryPoint是做什么用呢
      

  3.   

    试试:
    #pragma comment(linker, "/ENTRY:DllEntryPoint")如果你的 DLL 要用到 CRT 库的话,要在调用_CRT_INITBOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason,
        LPVOID lpReserved)
    {
        if (fdwReason == DLL_PROCESS_ATTACH || fdwReason == DLL_THREAD_ATTACH)
        {
            if (!_CRT_INIT(hinstDLL, fdwReason, lpReserved))
                return FALSE;
        }    if (fdwReason == DLL_PROCESS_DETACH || fdwReason == DLL_THREAD_DETACH)
        {
            if (!_CRT_INIT(hinstDLL, fdwReason, lpReserved))
                return FALSE;
        }    return TRUE;
    }
      

  4.   

    DllEntryPoint是Borland C++ Builder 的默认动态库入口函数
      

  5.   

    补充一下:默认情况下,DLL 的入口指向 CRT 函数 _DllMainCRTStartup ,即设置:/ENTRY:_DllMainCRTStartup@12这时作为 DLL 入口的函数是 DllMain