Checking if an exe file is running with c++
Hi I have two seperate exe files and I am looking for some ideas as to how I can deterimine if the other one is running so I can set the other one to sleep. Any help would be most appreciated :)
[Edited by - Z4Gamer on December 15, 2004 7:23:13 AM]
You can use CreateMutex() to create a named mutex in one application, and then try to create a mutex with the same name in the other one. If the other application is running, GetLastError() will return ERROR_ALREADY_EXISTS.
I am current executing the second file using this
WinExec("Application.exe",SW_SHOWMAXIMIZED);
Is there any other way I can check to see if its running without using Mutex as I have had lots of problems with them in the past :eek:
WinExec("Application.exe",SW_SHOWMAXIMIZED);
Is there any other way I can check to see if its running without using Mutex as I have had lots of problems with them in the past :eek:
Just thought of something: Use CreateProcess() to start the application, and save the process id, which you can then use with OpenProcess() to see if it's still running. Check MSDN for details.
Don't futz around with hidden windows and the like, especially when running a console app. Using a mutex is the way to go.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement