943,793 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 8038
  • C++ RSS
Apr 6th, 2009
0

get hwnd from process id

Expand Post »
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

C++ Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 10
Solved Threads: 8
Posting Whiz in Training
nschessnerd is offline Offline
216 posts
since Dec 2006
Apr 6th, 2009
0

Re: get hwnd from process id

Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Apr 6th, 2009
0

Re: get hwnd from process id

how do i get the thread id?
Reputation Points: 10
Solved Threads: 8
Posting Whiz in Training
nschessnerd is offline Offline
216 posts
since Dec 2006
Apr 6th, 2009
0

Re: get hwnd from process id

use CreateProcess() instead of ShellExecute(). CreateProcess() will return a structure that contains the information you need.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Apr 6th, 2009
0

Re: get hwnd from process id

I'm not a .NET programmer but according to the documentation:
C++ Syntax (Toggle Plain Text)
  1. IntPtr hwnd = process->Handle;

Which compiles successfully as a CLR console program.
Reputation Points: 13
Solved Threads: 6
Light Poster
seanhunt is offline Offline
40 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Need help. Solution will probably include pointers.
Next Thread in C++ Forum Timeline: Copy Constructor





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC