Jump to content
  • Advertisement
Sign in to follow this  
JonW

Detect If Process Is Still Running (Solved)

This topic is 4615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, In my code I am storing a number of process IDs. I would like to be able to find out when one of these processes close. The only way I can think to do this is to perform some sort of check on each ID once per second or so. My question is, how can I quickly find out if a process is still running given only its process ID? I know about using WaitForSingleObject to check if a process is running given a HANDLE, but I don't have the HANDLE available--just the ID. If it matters, I'm getting the process IDs from HWNDs with GetWindowThreadProcessId. Thank You! Jon Woyame [Edited by - JonWoyame on November 29, 2005 1:09:41 PM]

Share this post


Link to post
Share on other sites
Advertisement
Would it be better to call OpenProcess to get the handle when I first retrieve the ID, and then just leave the handle open until the process ends, than to call OpenProcess on the ID every time I want to check that it is running?

The documentation doesn't give a whole lot of info on what OpenProcess actually does, besides the fact that it returns a handle. I didn't want to use a handle if creating it requires a bunch of extra resources to be allocated.


Thanks again.

Share this post


Link to post
Share on other sites
Yeah, create the handle once and keep it around. A process handle is really the Right Way for a process to know about another process. Process IDs are more a user-level thing.

Share this post


Link to post
Share on other sites
OK, great.

Response in < 5 minutes both times. Hmm... I'm beginning to wonder if you're an autoresponse bot ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!