Click to See Complete Forum and Search --> : DOS return code
whterbtobj
June 26th, 2009, 04:10 PM
How can I get the DOS return code when a process ended without waiting?
For example:
If I run format C:\
when format is completed it would return 0 if it was successful.
Can I use GetExitCodeProcess to get the return code?
S_M_A
June 26th, 2009, 06:20 PM
Yepp that's the right way as far as I understand from MSDN. Make sure you wait for the process to terminate though
whterbtobj
June 29th, 2009, 02:11 PM
What if I dont want to wait?
Ajay Vijay
June 29th, 2009, 02:48 PM
What if I dont want to wait? Okay. You don't wait! Then what would you do of return value? There should be some usage of return value, if you need return value. May be you can put the call to command (via CreateProcess/ShellExecute), and wait for it to complete in a separate thread.
whterbtobj
June 29th, 2009, 03:18 PM
That makes sense. Creating a separate thread.
But can't I do something like this?
while (STILL_ALIVE)
{
//do other stuff
}
//the program has closed
//get the return code
Ajay Vijay
June 29th, 2009, 03:24 PM
You can. Just specify 0 as timeout for WaitForSingleObject.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.