Hello everyone,
I have used the code supplied in the following CodeProject article in the past with success, but it only seems to partially work on Vista/7 (I'm guessing because of UAC). It works for the current thread, but it doesn't pick up system wide activity. I've tried adding requireAdministrator in the manifests and signing both the unmanaged and managed assemblies, and that doesn't appear to help.
Using Window Messages to Implement Global System Hooks in C#
My main goal is to use SetWindowsHookEx to catch the HSHELL_WINDOWCREATED and HSHELL_WINDOWDESTROYED messages in the unmanaged assembly, and notify the C# application so that it can use the information in real time. It basically just needs to know whenever a window is created or destroyed in the system.
I also found an example application that is pure C/C++ that works just fine in Vista/7, but I really don't want to have to write the entire application in C/C++ as I prefer C#.
System Wide Hook Example that Works
Anyone know how to fix the code in the first CodeProject article so that it works on Vista/7 as well? Or have any other examples of ways I can do this without creating timers and similar hacks in C#?
Thanks, Marc