2016-04-20 9 views
0

私の最初の質問はここにあります:D C++でMessageBoxを作成するDLLを作成しようとしていますが、この奇妙なエラーが発生します。 ...私はGoogleで検索が、何も私を助けていない:ここで/C++ DLLがMessageBoxを呼び出さない。 "Member MessageBoxが定義されていません"

私のコードです:

#include<windows.h> 

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 
{ 
    MessageBox(0, "DLL Loaded", "SUCCESS STATUS", MB_OK); //here is the error :(
    switch (fdwReason) 
    { 
    case DLL_PROCESS_ATTACH: 
     // attach to process 
     // return FALSE to fail DLL load 
     break; 
    case DLL_PROCESS_DETACH: 
     // detach from process 
     break; 

    case DLL_THREAD_ATTACH: 
     // attach to thread 
     break; 

    case DLL_THREAD_DETACH: 
     // detach from thread 
     break; 
    } 
    return TRUE; // succesful 
} 

任意のアイデアは?私はあなたの質問がここで回答されて見ることができます:(

答えて

2

前に同様の問題を抱えていたことはありません:DllMain() routine and MessageBox() function
rerun
でここで彼/彼女の答えである。

あなたがFreeLibraryをのLoadLibraryのかを呼び出すことができます任意の関数を呼び出すことはできませんDll mainは、非常に限定された初期化を行うためにのみ使用する必要があります。これは、ロジックを実行する場所ではなく、ライブラリへのエントリポイント

During initial process startup or after a call to LoadLibrary, the system scans the list of loaded DLLs for the process. For each DLL that has not already been called with the DLL_PROCESS_ATTACH value, the system calls the DLL's entry-point function. This call is made in the context of the thread that caused the process address space to change, such as the primary thread of the process or the thread that called LoadLibrary. Access to the entry point is serialized by the system on a process-wide basis. Threads in DllMain hold the loader lock so no additional DLLs can be dynamically loaded or initialized.

あなたはこれをしてはいけない理由を理解するためにこの質問を見ることができます。 Loading a dll from a dll?

関連する問題