It can be answer in C# or C++ or WinAPI (I know how to pInvoke).
What I want to achieve.
I want to get number of windows that are opened by another applicatoin.
For example I have Chat application. I want to get number of windows because I wan’t to detect if someone send me message (New incoming message = one more window).
So in short.
How to get number of windows opened by another process.
If you have the process ID of the other application, here’s a possible Windows API way:
Enumerate all top level windows with the EnumWindows function, using GetWindowThreadProcessId in the callback function to test for main windows belonging to your given process. From matching main windows you can then continue to enumerate all its child windows with EnumChildWindows.