"invalid hook procedure" error when I use SetWindowsHookEx() for WH_KEYBOARD, c++
Posted on 2007-08-06
I am trying to set a global Windows hook for WH_KEYBOARD messages.
I am using the following code:
hModule = LoadLibrary("C:\\myDlls\\hookDll.dll");
lpfn = (HOOKPROC)GetProcAddress( hModule,"GetMsgProc");
hHook = SetWindowsHookEx(WH_KEYBOARD,lpfn,hModule, 0);
When I try to set a hook for WH_GETMESSAGE, everything works fine. However, when I try to set the hook for WH_KEYBOARD, I get the "ERROR_INVALID_HANDLE" error.
Thanks in advance for your help.