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.

Recommended Answers

All 4 Replies

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

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.

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.

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.