DLL代码
#include <Windows.h>
BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{switch (ul_reason_for_call){case DLL_PROCESS_ATTACH:MessageBox(NULL, L"dllHook", L"Hook", MB_OK);break;case DLL_THREAD_ATTACH:case DLL_THREAD_DETACH:case DLL_PROCESS_DETACH:break;}return TRUE;
}
exe代码
#include <Windows.h>
#include <cstdio>int main()
{HINSTANCE dllHins = LoadLibrary(L"hookNotepadDLL.dll");if (dllHins == NULL) {printf("Load Failed\n");}else {printf("Load Success\n");}return 0;
}
结果