Board index » cppbuilder » Checking if a process is alive...

Checking if a process is alive...


2006-04-01 12:45:45 AM
cppbuilder0
how can i tell if a process is alive if i have it's process ID?
thanks
 
 

Re:Checking if a process is alive...

"peter" < XXXX@XXXXX.COM >wrote in message
Quote
how can i tell if a process is alive if i have it's process ID?
You have to enumerate through all of the running processes until you find
(or don't find) the ID. Look at the following article for details:
How To Enumerate Applications Using Win32 APIs
support.microsoft.com/default.aspx
Gambit
 

Re:Checking if a process is alive...

Remy Lebeau (TeamB) wrote:
Quote

You have to enumerate through all of the running processes until you find
(or don't find) the ID. Look at the following article for details:

How To Enumerate Applications Using Win32 APIs
support.microsoft.com/default.aspx


Gambit


What about re-used PIDs? Is that a possibility?
 

{smallsort}

Re:Checking if a process is alive...

"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
What about re-used PIDs? Is that a possibility?
The enumeration provides the full path and filename of each process with
their IDs. The process that is checking the ID can also check if the ID
still matches the intended .exe file. Unless the OS reuses the same ID for
the same .exe file, it should be ok. Using OpenProcess() alone to see if
the ID is a valid process would not be able to detect that.
Gambit
 

Re:Checking if a process is alive...

Remy Lebeau (TeamB) wrote:
Quote
>how can i tell if a process is alive if i have it's process ID?


You have to enumerate through all of the running processes until you find
(or don't find) the ID. Look at the following article for details:

How To Enumerate Applications Using Win32 APIs
support.microsoft.com/default.aspx
Or you could do it the simple way (not on 9X/ME though) and use
OpenProcess/GetModuleFileNameEx
--Erik