I’d like to use SetWindowHookEx to catch WM_CREATE (or HCBT_CREATEWND) messages in a process before a creation of a window.
Using the hMod and dwThreadId it is possible to define whether the hook will be system-wide (by setting hMod to be the gInstance of the DLL and dwThreadId to 0), it is also possible to use it to monitor a SINGLE thread in a process (hMod = 0, and dwThreadId = ThreadToMonitorId).
However, I’d like to monitor multiple threads. Is it possible? I guess I can simply call SetWindowHookEx for multiple threads but I’d rather not as it would make things more complex. Are there other alternatives?
Thanks!
It is very unusual for a process to create more than one thread that owns a UI window. Sometimes it is a interop window which is intentionally hidden, unlikely that you’d want to know about it. Verify your assumptions with Spy++, the owner thread ID is shown in the window properties, Process tab.
If it does have more than one thread creating windows that you want to know about then you’ll want to set separate hooks.