Posted on 1999-07-18
This is my first time using the Expert Exchange. I was not aware of it before today.
I am trying to get a system-wide hook to work. Everything is working except the hooks are not system-wide. I have written a DLL and an MFC SDI application to invoke the DLL. The DLL does the SetWindowsHookEx, specifies a callback within itself, specifies zero for threadid, and saves the hook handle in a global variable. The DLL does not use MFC. Everything works, except I only get hooked into my MFC app that calls the DLL. I tried the keyboard and mouse hooks first. I get keyboard and mouse messages but only from my program. So I tried the WH_SYSMSGFILTER hook with similar results. I have set breakpoints in the hook procedures and I get breaks only for hooks from my program.
I have looked at the HOOKS sample from the Microsoft "Win32 Hooks" article. I confess that this is the first DLL I have written. Since the HOOKS sample is a c program (not cpp) and uses things like LibMain it is hard to know what it does differently to make a difference. I do not see anything relevant to my program that it is doing differently.
I have searched the MSDN as much as I can and I have done everything else I can find to do to get hooks into other apps.
I realize that it would help to have the complete source for my DLL to look at but if someone has encountered a problem like this and is aware of something relatively obscure then please let me know.
Otherwise I am sure it is something simple that I am just overlooking.