#include <windows.h>
DWORD WINAPI Main(LPVOID lpParam) {
MessageBox(0,"Hello World from DLL!\n","Hi",MB_ICONINFORMATION);
return S_OK;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
CreateThread(NULL, 0, &Main, NULL, 0, NULL);
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
为什么我可以替换CreateThread(NULL, 0, &Main, NULL, 0, NULL);
它CreateThread(NULL, 0, Main, NULL, 0, NULL);
并且它仍然可以工作?是因为在 C 中,如果我传递一个方法,它会将其简化为指向该方法的指针吗?还是因为DWORD
是指针?