Hi 2 all!
I have a problem with hooks! I wrote a function in my dll, wich i call from the main program. Here is the text of my dll and the main code:
__declspec(dllexport)LRESULT CALLBACK HookProcedure(int code, WPARAM wParam, LPARAM lParam)
if(code<0) return CallNextHookEx(hHook, code, wParam, lParam );
MessageBox(NULL, "HOOK!", "hook", 0);
return CallNextHookEx(hHook, code, wParam, lParam );
When my program starts, it receives mesages from keyboard and show message box. But after i minimize my program the hook doesn't work. It seems like i set an a local hook, without using dll.
#pragma comment(lib, "myhookdll")
__declspec(dllimport)LRESULT CALLBACK HookProcedure(int ,WPARAM, LPARAM);
hHook = SetWindowsHookEx( WH_KEYBOARD, (HOOKPROC)HookProcedure, GetModuleHandle(NULL), 0 );
if( hHook == NULL )
wsprintf(c, "%d", GetLastError());
MessageBox(hwnd, c, "Can't set hooK", 0);
Help, plz. What is the problem?!