Hi All
I am attempting to install a low level keyboard hook using the following calls:
HANDLE hDll = LoadLibrary(DLL_NAME);
LPVOID procAddress = GetProcAddress(hDll, "HookProc");
HHOOK wHook;
wHook = SetWindowsHookEx(WH_KEYBOARD_LL, procAddress, hDll, 0);
I have built a DLL containing HookProc define below:
__declspec (dllexport) LRESULT CALLBACK HookProc (int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{
return CallNextHookEx(0, nCode, wParam, lParam);
}
if(nCode == HC_ACTION)
{
if(wParam == WM_KEYDOWN)
{
printf("Keyboard Event Detected\n");
return 1;
}
}
return CallNextHookEx(0, nCode, wParam, lParam);
}
When I run my code; I get no run time errors and the values for Dll, procAddress and wHook returned seem reasonable (I don't get any NULLS) but my keyboard hook (HookProc) is never called.
Any thoughts on this matter would be greatly appreciated.
Regards
Steve