我正在写一DllMain的是这样的:Dllmain未被调用?
#include "main.h"
#include "init.h"
#include <iostream>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
//std::cout<<"hi\n"; //only for debug. did not shown.
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
//std::cout<<"hello\n"; //only for debug. did not shown.
init(); //did not run :(
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
}
,但使用的LoadLibrary测试程序()后,什么都没有发生, 没有打招呼或喜在屏幕上。 你想知道这个问题吗?非常感谢!
P.S.我看过这个问题DllMain not being called 但它仍然没有帮助。
PS2:主叫程序就像是
int main()
{
cout<<"This is a test program to test.\n";
HINSTANCE hinstDLL;
hinstDLL=LoadLibrary("ijl15.dll");
cout<<"Look like everything goes well.\n";
cout<<hinstDLL;
return 0;
}
的测试程序的输出:
This is a test program to test.
Look like everything goes well.
0x6a980000
Process returned 0 (0x0) execution time : 0.007 s
Press any key to continue.
嗯...看起来好吧...你可以添加LoadLibrary()代码吗? 此外,只是为了确定 - 你正在寻找打印输出在控制台窗口,对吧? – TCS 2011-05-28 13:16:38
我很乐意看到init()运行;但它永远不会所以我尝试了一些cout,但它仍然不起作用 – xxbidiao 2011-05-28 13:20:04
你的连接器开关是什么? – 2011-05-28 15:47:15