Is there a way, or what is the 'accepted' way to get all the windows running under the current process?
From the process address space of another app how would you get a ha开发者_如何学Cndle to each window that it is using/displaying?
I know you can get a snapshot of all the current threads running within a process http://msdn.microsoft.com/en-us/library/ms686701(v=vs.85).aspx but I am wondering if there is a way, using the THREAD ID to then get a hwnd value that you can the test using IsWindow(hwnd), or logically if you can get a hwnd don't you know you already have a value window? But I am wondering if this would work or if indeed it is a sensible approach?
Thanks.
You can use EnumThreadWindows to enumerate all nonchild windows associated with a thread, and then use EnumChildWindows to get all their child windows.
Alternatively, you can use EnumWindows to get all top-level windows on the desktop, and use GetWindowThreadProcessId to filter to only those associated with the process.
Note that this information is very dynamic. Windows come and go all the time. Top level windows will often be the most persistent, but even these can disapear right after you 'find' them, or new ones apear right after you look for them.
精彩评论