get hwnd from process id

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2006
Posts: 195
Reputation: nschessnerd is an unknown quantity at this point 
Solved Threads: 8
nschessnerd's Avatar
nschessnerd nschessnerd is offline Offline
Junior Poster

get hwnd from process id

 
0
  #1
Apr 6th, 2009
Hey
so as i mentioned here http://www.daniweb.com/forums/post840142.html i need to check if a process is responding by using sendmessage
however i have no idea how to get the hwnd because i start the process using system::diagnostics::process

  1. process->StartInfo->WorkingDirectory=sinfo->workingDirectory;
  2. process->StartInfo->Arguments=" -exec "+sinfo->init+" -port "+sinfo->port+" "+sinfo->options;
  3. process->StartInfo->FileName = sinfo->exe;
  4. process->StartInfo->UseShellExecute=true;
so this program starts in a console, so does it not have a handle?

its a really weird program... a halo server, the program takes over the console window.... so is it possible to send it a message?

how do i get the hwnd from pid?
process->Mainwindowtitle and mainwindowhandle dont return anything

yea im confusing myself... understand?
this.love(*);
&hea/rts;
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,433
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: get hwnd from process id

 
0
  #2
Apr 6th, 2009
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 195
Reputation: nschessnerd is an unknown quantity at this point 
Solved Threads: 8
nschessnerd's Avatar
nschessnerd nschessnerd is offline Offline
Junior Poster

Re: get hwnd from process id

 
0
  #3
Apr 6th, 2009
how do i get the thread id?
this.love(*);
&hea/rts;
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,433
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: get hwnd from process id

 
0
  #4
Apr 6th, 2009
use CreateProcess() instead of ShellExecute(). CreateProcess() will return a structure that contains the information you need.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 40
Reputation: seanhunt is an unknown quantity at this point 
Solved Threads: 6
seanhunt seanhunt is offline Offline
Light Poster

Re: get hwnd from process id

 
0
  #5
Apr 6th, 2009
I'm not a .NET programmer but according to the documentation:
  1. IntPtr hwnd = process->Handle;

Which compiles successfully as a CLR console program.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC