Win API: Hook every window show or process execution
We're planning to build some sort of single sign-on feature inside our app.
It's clear to me that I'll have to go depp with Windows API to achieve reading and writing from legacy applications controls, but as far as I've searched and tested that's not the hardest part of the job.
There's a point, however, that I couldn't figure out until now how to proceed with: how can I "hook" the system to be notified every time a new window pops up in the UI? By example: when I start my calculator or when, inside calc, the About window is ope开发者_如何学JAVAn.
Is there a way to receive this kind of notification? If yes, how? If no, is there any workaround to achieve the same result?
Thank you in advance,
Filipe
You need a windows system hook, specifically a WH_CBT hook, watching the HCBT_CREATEWND event. This stuff is a bit hairy, but possible.
Start here:
Use SetWinEventHook with EVENT_OBJECT_SHOW event type. Call UnhookWinEvent at the end.
Similar example: https://stackoverflow.com/a/10280800/991267
精彩评论