Tag: setwindowshookex hinstance

当用户点击一个键时显示一条消息

以下代码段用于在用户键入密钥时显示消息。 即使重点不在于应用程序。 但是以下代码似乎存在问题。 它不会使用windows调用挂钩链中注册的函数。 我猜问题是HINSTANCE hInst 。 我应该如何修改以下代码,以便在用户点击密钥时能够看到该消息。 // Global Variables static HHOOK handleKeyboardHook = NULL; HINSTANCE hInst = NULL; void TestKeys_setWinHook // i call this function to activate the keyboard hook (…) { hInst = GetModuleHandle(NULL); handleKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hInst, 0); // LowLevelKeyboardProc should be put in the hook chain by the windows,but […]