i want to know that how can we keep an eye on one process that its alive or terminated , actually i have service which will always check my process if my process terminated then service will start it again so i want to know how to check process status using winapi , asume i have process pid so how to keep checking its status


Deleted Member

I've found this in my personal helpfile. It may give you a start/clue/hint:

   HANDLE hSnapShot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS,0) ;

   if (-1 == (int)hSnapShot) {

       WalertBox ("Could not open snap shot") ;


   PROCESSENTRY32 Process ;

   Process.dwSize = sizeof(PROCESSENTRY32) ;

   if (Process32First(hSnapShot,&Process)) { 

       do {

           WalertBox ("Process %s ",Process.szExeFile) ;

       } while (Process32Next (hSnapShot,&Process)) ;

   } else {

       WalertBox ("Could not get first process") ;


if you just want to check if your process is still alive or dead using the process id (pid) you have, calling the OpenProcess API would suffice.

ok i done it with WaitForSingleObject() :)

This question has already been answered. Start a new discussion instead.