Difficulty using GetExitCodeProcess

Hello guys, i would like to do a program that check if a program named MyProg.exe is running in background. Reading on the internet, It is recommended to use GetExitCodeProcess. So i read https://msdn.microsoft.com/en-us/library/ms683189(VS.85).aspx but i don't understand. Can someone explain me better please?
Last edited on
What exactly do you mean by "running in background"? Do you mean running as a service? Or running as a child of your program? Or running as a child of some other program kicked off in the session?

GetExitCodeProcess() returns the exit code of a process once it has closed. A process is uniquely identified from its process handle (hProcesses). You typically get the handle when you call CreateProcess(), but if you didn't create it, you kinda have to jump thru hoops to get the process handle.

Also, you should move this to the Window Programming Group as it's not General C++.
Last edited on
Maybe you want to enumerate the processes on your system:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623(v=vs.85).aspx
Thanks for the replies. I move this post to the Windows Programming. Anyway, i did a program in c++. With another program i would like to check if my first program is running, if it is not running I'd like to run it. I see that to check if a program is running i need to use GetExitCodeProcess. I said background because i hide the console of my first program, so i can't use FindWindow to check if it is running. The program is not the child, they are 2 independent programs.
summing: i have myprog.exe and myprog2.exe, with myprog2.exe i would like to check if myprog.exe is running, else if myprog.exe is not running, myprog2.exe must run myprog.exe
P.S. sorry for my bad English
Last edited on
Topic archived. No new replies allowed.