mardi 26 septembre 2017

Cannot get the callback for windows focus change using hook proceduce

I am using this method to install local hook to detect change in window, HHOOK hHook = SetWindowsHookEx(WH_CBT,CBTProc,NULL,(DWORD)GetCurrentThreadId());

The callback function is here,

LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam) {

 printf("got the window\n");`

 if (code == HCBT_SETFOCUS){

    printf("Here i got the window\n");
}
return CallNextHookEx(0, code, wParam, lParam); }

This callback function doesnt get called. I tried using WH_SHELL WITH setwindowshookex that also didnt get called. However, the return of hHook is fine and there is no error as i printed the lasterror() also. May be i am missing something. Is the dll necessary to be created? or i can do it directly using exe.

Aucun commentaire:

Enregistrer un commentaire