The Accessibility API's SetWinEventHook
filtering for EVENT_OBJECT_DESTROY
.
This is notification based so no polling and unlike a CBT hook does not require injection.
Question
Is there a method for setting up a listener/watcher to know when an unrelated application window is closed?
I can check to see if the window is still open, but that seems silly to continually do.
Solution
The Accessibility API's SetWinEventHook
filtering for EVENT_OBJECT_DESTROY
.
This is notification based so no polling and unlike a CBT hook does not require injection.
OTHER TIPS
You can:
HWND
validity (esp. if you don't need timing precision)WM_DESTROY
and then forward the notification to your app