PID detection

June 05th, 2008 - 07:58 pm ET by Ed | Report spam
I need to test PIDs of executable files to see if they are still active.

So what's the best/fastest way to detect if a given ProcessID is still
running? I was going to just run a GetExePath(PID) function but figured
there may be faster/better ways to check this, is there an IsProcessID
like IsWindow type API?

Thanks for any input,
Ed
email Follow the discussionReplies 1 replyReplies Make a reply

Similar topics

Replies

#1 expvb
June 05th, 2008 - 09:14 pm ET | Report spam
"Ed" wrote in message
news:
I need to test PIDs of executable files to see if they are still active.

So what's the best/fastest way to detect if a given ProcessID is still
running? I was going to just run a GetExePath(PID) function but figured
there may be faster/better ways to check this, is there an IsProcessID
like IsWindow type API?



Use GetExitCodeProcess or WaitForSingleObject. You need to call OpenProcess
first. If you keep the handle open even if the process has ended, the system
keeps the process object in memory until all handles to it are closed. This
means that you can check the status later without worrying if Windows reused
the process ID for something else. If you open and close the handle for each
check, then there is no guarantee that the process you are checking is the
same as the one you checked before.

If you search the newsgroups for these functions, you will find a lot of
samples.
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search