Member Avatar for nova37

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

thanks

Recommended Answers

All 3 Replies

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.

Member Avatar for nova37

ok i done it with WaitForSingleObject() :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.