dominochmiel
Programmer
I wrote a program using hook(it doesn't matter is this keyboard hook or message hook or else) which works perfectly until I don't want to capture all messeges or key events in system. It works only when identifier of the thread with which the hook procedure is to be associated is HInstance. But then hook intercept only messeges in my app not in system. Below I'm enclosing app code(this working). Maybe somone can correct me and show what is incorrect.
void *hook;
LRESULT HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode==HC_ACTION)
ShowMessage(char(wParam));
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
hook=SetWindowsHookEx(WH_KEYBOARD_LL ,HOOKPROC(HookProc),HInstance,NULL);
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
UnhookWindowsHookEx(hook);
}
Thanks for help.
void *hook;
LRESULT HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode==HC_ACTION)
ShowMessage(char(wParam));
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
hook=SetWindowsHookEx(WH_KEYBOARD_LL ,HOOKPROC(HookProc),HInstance,NULL);
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
UnhookWindowsHookEx(hook);
}
Thanks for help.