c++ - Global Keyboard hook not working -


I created a global keyboard hook.

The hook is built in a DLL.

  #pragma comment (linker, "/SECTION:.SHARED,RWS") #pragma data_seg (shared ".") High HHOOK HKB = null; Fixed CMyFile * PLF; #pragma data_seg () Hintus Hins = Faucet; Exile 'C' LRESULT __declspec (dllexport) __stdcall callback KeyBoardHookProc (int nCode, wParam wParam, lParam lParam) {if (nCode & LT; 0) {return CallNextHookEx (0, nCode, wParam, lParam); } Return CallNextHookEx (HKK, Encoded, WPAMM, LPARM); } Extern "C" LRESULT __declspec (dllexport) __stdcall Install Callback () {PLF = New CMyFile (L "C: \\ 1.txt"); Hkb = SetWindowsHookEx (WH_KEYBOARD, (HOOKPROC) KeyBoardHookProc, hins, 0); Return 0; } Extern "C" BOOL __declspec (dllexport) __stdcall uninstalled callback () {return UnhookWindowsHookEx (HKB); } BOOL APIENTRY DllMain (HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {switch (ul_reason_for_call) {case DLL_PROCESS_ATTACH: HINS = (HINSTANCE) hModule; break; Case DLL_THREAD_ATTACH: break; Case DLL_THREAD_DETACH: break; Case DLL_PROCESS_DETACH: break; } Return TRUE; }  

I have loaded a Dell and installed the call of the hook DLL phone. "); If (hMod! = NULL) {typedef LRESULT (__stdcall callback * _installhk) (); _installhk installProc; InstallProc = (_installhk) GetProcAddress (hMod," Install "); if (installProc! = NULL) {installProc ( );}}

debugging breakpoints on KeyBoardHookProc being struck only once, but when I launch the exe.

exe unless I am running close But if I enter anything

what might be the reason for this?

Is not this the correct way to set the global keyboard hook?

come Has not said how tested that hook procedure? If you try to check it breakpoint, you are loaded every hook DLL that will take care of every process, but your breakpoint only in your current process

If you have an app, focus it before killing the keys or debug it using logs.

Another solution Not to hook up with WH_KEYBOARD_LL, which does not require any additional DLL. You can hook directly through your process.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -