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.
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.
quoted from C++ Coding Standards:
KISS (Keep It Simple Software):
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
Avoid magic number:
Programming isn't magic, so don't incant it.