Re: Check if a program runs?
You can use log file to record when the program has shutted down.
Re: Check if a program runs?
You can look for a process having a specific name using the Toolhelp32 API. CreateToolhelp32Snapshot, Process32First and Process32Next are the functions you want to use.
Another way is to use a "starter" Application that starts the target application by calling CreateProcess. CreateProcess fills a PROCESS_INFORMATION structure that contains the PID of the newly created process, so you look for that process using its PID. If there´s no process with that PID you´ll have to restart it.
Re: Check if a program runs?
Is the program you want to monitor developed by you or published by others?
Re: Check if a program runs?
You can create an interprocess semaphore object. When the first program starts, it creates an interprocess semaphore with an unique name. When subsequent instances of the same program is launched, they will fail creating the semaphore will the same name because the first had already created one. From here, subsequent instances can quit gracefully.
A good reason for using the semaphore is when the first instance of the program is killed, the semaphore will be automatically destroyed.
Re: Check if a program runs?
Quote:
Originally Posted by
Lzj
Is the program you want to monitor developed by you or published by others?
It's not published by me. It's made by someone else. And it's NOT in a graphical interface.
Sorry for posting back this late, I forgot I had this thread :)