System wide CBT-Hook reacts only to windows in creating process
-
Hi! I need to be able to control the life time of a window that was created in a different process. For that purpose I set a CBT-hook to check for the HCBT_DESTROYWND notification. The problem is that I only get notifications for destroyed windows that were created by threads in my own process. The hook callback function is, as the docs request, in a separate dll. I use this function call to set the hook: ::SetWindowsHookEx(WH_CBT, _CBTProc, hInstance, NULL); Here, hInstance is the handle to the loaded separate dll and _CBTProc is the pointer to my callback inside that dll. As I said: it works, I get notifications, but ONLY for windows owned by threads in my process. That's not what I consider a "system wide" hook! As a workaround I also tried to get the ID of thread owning the window I want to be informed about via GetWindowThreadProcessID() and used that ID instead of the NULL parameter when setting the hook - to no avail... In this same separate dll I use a system wide mouse hook. This mouse hook _does_ work however. So my question is: did I miss something important concerning CBT hooks? How can I get a really system wide CBT hook installed? Thanks in advance Nick