Sign in to follow this  
JonW

Detect If Process Is Still Running (Solved)

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this