Question: How to get a window handle from a process ID 
Author Message
 Question: How to get a window handle from a process ID

NT 4.0 sp3
VC++ 5.0

Hello,

I have an MFC application that starts other applications via CreateProcess.
This will return the Process ID, etc. in a PROCESS_INFORMATION struct.  What
I would like to do is get the main (top level) window handle for this new
process, if possible.

Thanks for any help,

Barry Hurt



Fri, 19 Jan 2001 03:00:00 GMT  
 Question: How to get a window handle from a process ID
Do s search on deja news (http://www.dejanews.com )  I did and advance
search with teh following query

"window and handle and process and ID"

It came up with something like 800+ hits, looking thru the first 50 or so I
found several that may help (I don't think the URL willhelp since it has
context info specific to my search??)

Probably the most common answer I read was;

 > How can I get a window handle from process
 > id which I got from OpenProcess ?
EnumWindows(). In your EnumWindowProc(), call GetWindowThreadProcessId()
and compare the returned PID to the one you are looking for. Note: What
you got from OpenProcess() was a handle, not a PID.



Fri, 19 Jan 2001 03:00:00 GMT  
 Question: How to get a window handle from a process ID
Use EnumWindows() to enumerate all top level windows. Inside your
enumeration procedure, call GetWindowThreadProcessID() to get the window
owner's Process ID, and compare it with the ProcessID you have.

Tomas Restrepo

http://www.geocities.com/SiliconValley/Heights/3401

Quote:

>NT 4.0 sp3
>VC++ 5.0

>Hello,

>I have an MFC application that starts other applications via CreateProcess.
>This will return the Process ID, etc. in a PROCESS_INFORMATION struct.
What
>I would like to do is get the main (top level) window handle for this new
>process, if possible.

>Thanks for any help,

>Barry Hurt




Sat, 20 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting process ID from process handle

2. window handle from process id

3. !Help: How to get Window handle from Process ID

4. Getting a window handle using control id

5. Process id from process handle (how to get)?

6. How to obtain Process ID If I have process handle

7. Process ID from Process Handle

8. Process ID from Process Handle

9. getting process ID of the current process

10. Getting window handle for a process

11. Getting the handle of a given process's main window

12. process handles and ids

 

 
Powered by phpBB® Forum Software