How to check if an application finished working?

Started by
4 comments, last by mikeman 17 years, 4 months ago
I'm executing a console application (via ShellExecute). And it does some calculations. How to check if that application finished working (it should return 0 when it finishes)? I'm doing this in c++ on windows (winapi). Thanks in advance!
Advertisement
I'm not sure you can do that with ShellExecute. You can, however, launch an application using CreateProcess and use WaitForSingleObject to wait until it finishes. Take at look at this MSDN link: Creating Processes
Yeah, CreateProcess and WaitForSingleObject is the way to go here. ShellExecuteEx doesn't return anything that you can actually work with.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Ok, I'll try that. Thanks
That solved the problem, but made a new one. The application I execute (via CreateProcess) writes it's output in my console application (in the one that executed it - parent). How to stop it? (so it doesn't write it's output in parent's process 's console)

Thanks in advance!
Check out the documentation for CreateProcess. In the dwCreationFlags parameter, you must set the CREATE_NEW_CONSOLE flag.

This topic is closed to new replies.

Advertisement