Question

I first get handle to a process by using OpenProcess. Then I call GetExitCodeProcess in a loop to see if the process is running. But how does GetExitCodeProcess get exit code? Does Windows store exit code of all processes that ran in the past 30 minute or something? As soon as the application exits, any information regarding the process is wiped out from Windows. I don't know how GetExitCodeProcess can get exit code of something that no longer exists...

Était-ce utile?

La solution

The exit code is saved in the process object, which is destroyed when the last handle is closed. So don't close that handle until you're really done!

Autres conseils

I think Windows holds on to the process exit code until all handles to the process have been closed. The OpenProcess documentation says:

This function returns a handle to an existing process object. When you finish with the handle, close it using the CloseHandle function.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top