I am trying to install a Shell system-wide hook but because I have to put the application-defined procedure (ShellProc) in a dll, so I have created a simple dll using ATL and so far it's working all right.
Here is the procedure which is in a dll:
There's also a function called "StartHook" in the same dll which actually sets the the WH_SHELL hook using SetWindowsHookEx(). So whenever I call the StartHook function, I start getting the message boxes above correctly but....PHP Code:LRESULT WINAPI ShellProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your implementation code here
switch(nCode)
{
case HSHELL_WINDOWCREATED:
MessageBox(NULL,"","Window Created", MB_OK);
break;
case HSHELL_WINDOWDESTROYED:
MessageBox(NULL,"","Window Destroyed", MB_OK);
break;
default:
break;
}
return CallNextHookEx(hhook, nCode, wParam, lParam);
}
I'll have to perform on the messages (ex HSHELL_WINDOWSCREATED) inside the dll because the procedure is inside the dll. How can the calling thread (or me if I am using this dll) be notified which message is recieved? Will have to write my own for getting the address of a CALLBACK message from the programmer and then call that function from the dll? Or will it actually work?




Reply With Quote