LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam){
OutputDebugString(L"---------------------------事件");
return CallNextHookEx(hookResult, nCode, wParam, lParam);
};
BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD dwReason, void* lpReserved)
{
HINSTANCE g_hModule;
switch(dwReason)
{
case DLL_THREAD_ATTACH:
{
g_hModule = hModule;
HWND h=FindWindow(NULL, L"333");
DWORD id;
LPDWORD pid=&id;
hookResult = SetWindowsHookEx(WH_KEYBOARD,MouseProc,hModule,GetWindowThreadProcessId(h,pid));
if (hookResult == 0)
{
OutputDebugString(L"---------------------------失败");
}
else
{
//MessageBox(NULL, L"成功", L"失败", 0);
OutputDebugString(L"---------------------------成功");
}
}
break;
case DLL_PROCESS_DETACH:
std::cout<<"Dll is detached!"<<std::endl;
g_hModule=NULL;
break;
}
return true;
}