0

hi,

I have one query that create process funcion retuns bool value.
And i want to know the exit code of my exe which i ran through create process function.

EX.

int main()
{
        return 5;
}

this exe is returning 5. I ran that exe by createprocess but GetExitCodeProcess function is returning 0.

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by ashishchoure
1

After calling CreateProcess() call WaitForSingleObject(). When that returns then you can call GetExitCodeProcess()

0

yes. I did that but even it is returning 0. I added Sleep(5000) also in code but not getting desire output.

//
DWORD dwWaitResult = WaitForSingleObject ( pi.hProcess, INFINITE ) ;

if ( WAIT_OBJECT_0 == dwWaitResult )
{
// Call to GetExitCodeProcess()
}

Is this Right? I can give the actual code also if you required.

0

What computer language was used to create the program you are spawning ? I know some MFC programs return 0 back to the os regardless of what the programmer intended -- hopefully M$ has corrected that by now. If it was written in C or C++ that problem should not occur.

Write a short little program that does nothing more than create the process and get its exit code status to see if the problem is elsewhere in your larger application. Sometimes its easier to debug with much smaller programs.

0

Yes you are right it is working for this small exe.
Ok now let me find out the problem for original program.

Thanks for the help Ancient Dragon :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.