-
September 9th, 2007, 03:09 PM
#1
Get Process Window
Hello,
I have a process handle. How can I get a HWND to it's main window?
I couldn't find any function in MSDN that does this.
Thanks
-
September 9th, 2007, 04:15 PM
#2
Re: Get Process Window
One soilution can be the following
[ Redirected thread ]
Last edited by ovidiucucu; September 9th, 2007 at 04:29 PM.
-
September 9th, 2007, 09:46 PM
#3
Re: Get Process Window
So I have to do it backwards from the window to the process...
-
September 10th, 2007, 02:41 AM
#4
Re: Get Process Window
Well, I think, there is not a kind of "GetProcessMainWindow" function because in a process can be created zero, one, or many (top-level) windows.
So... which can we say "that's the process main window" ?
BTW. How did you get the process handle?
Last edited by ovidiucucu; October 5th, 2007 at 02:05 AM.
Reason: Added a question mark
-
September 23rd, 2007, 09:03 PM
#5
Re: Get Process Window
I am using EnumProcesses() to find a specific window.
I know we can't determine the main window. I thinking of something like GetAllProcessWindows()...
-
October 4th, 2007, 01:23 PM
#6
Re: Get Process Window
You should be able to do that in the loop.
VB.NET
Code:
For Each p as Process In Process.GetProcesses
If p.Handle.ToInt32 = YourPHandle AndAlso p.MainWindowHandle.ToInt32 <> 0 Then
MessageBox.Show(p.MainWindowHandle.ToInt32.ToString)
End If
Next
Last edited by TT(n); October 4th, 2007 at 01:33 PM.
-
October 4th, 2007, 02:25 PM
#7
Re: Get Process Window
 Originally Posted by nemok
Hello,
I have a process handle. How can I get a HWND to it's main window?
I couldn't find any function in MSDN that does this.
Thanks
Look also at ::GetGUIThreadInfo(). 
Cheers
-
October 5th, 2007, 02:11 AM
#8
Re: Get Process Window
 Originally Posted by golanshahar
Does that help more to find out the process main window?
See my previous question (re)mark:
 Originally Posted by me
... which can we say "that's the process main window"  ?
-
October 5th, 2007, 10:01 AM
#9
Re: Get Process Window
 Originally Posted by ovidiucucu
Does that help more to find out the process main window?
See my previous question (re)mark:
Your comment is correct we cant, but that API can be an alternative for using ::EnumWindows(), you can get the active/focus window without enum the windows... then ::GetAncestor() can be used on the focus/active window... but no one can guarantee if it will lead to the Main Process window , UNLESS Op want to track specific process and not random one, so one look in Spy++ can help him know the windows structure of that specific process.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|