Click to See Complete Forum and Search --> : Check if program is running


Xadoom
June 1st, 2004, 07:24 AM
I had to check if a program is alredy running, this program is console-mode. Can i use API? How?
I know only the name of the exe (like test.exe) that i want to know if is running....
Thanks.:wave:

Xadoom
June 1st, 2004, 07:33 AM
Solved....:cool:

CreateMutex(NULL, FALSE, nome_exe);
if (GetLastError() == ERROR_ALREADY_EXISTS)return 0;

:wave:

Bond
June 1st, 2004, 09:38 AM
You should probably release any mutex handle generated from the CreateMutex function:

HANDLE hMutex = CreateMutex(NULL, TRUE, g_szAppName);
BOOL bAlreadyRunning = (GetLastError() == ERROR_ALREADY_EXISTS);
ReleaseMutex(hMutex);

Andreas Masur
June 1st, 2004, 10:04 AM
Always check the FAQs (http://www.codeguru.com/forum/showthread.php?s=&threadid=231178) first... :cool: