hOw to provide exit code to ExitProcess()?

    I have created a process using

    I will terminate the Process by calling


     The question is .. how do i get the fuExitCode for funcion ExitProcess()??

Who is Participating?
alikoankConnect With a Mentor Commented:

GetExitCodeProcess takes two parameters, one is handle to process, second is a variable to receive exit code.

You already know the handle to process, it is in PROCESS_INFORMATION structure you used when you called CreateProcess.

DWORD result;
CreateProcess(..., &pi);
GetExitCodeProcess(pi.hProcess, &result);

if (result == STILL_ACTIVE) {
    //process has not terminated yet
} else {
   //process terminated

If you want to get this exit code from your original process use GetExitCodeProcess function, or if you wonder what should fuExitCode must be, it is up to you.

Programs generally use 0 (zero) as an exit code to indicate that they finished execution normally. You can return any unsigned integer value to indicate errors etc.

For more information look at:
maxemillion_maxAuthor Commented:
actually i have come to that link already... thanks you..
maxemillion_maxAuthor Commented:
:) can u give a simple example of using ExitProcess() with GetExitCodeProcess() .... i would appreciate it... because i am stucked when come into  terminating a Process using ExitProcess() function.... I had use TerminateProcess() function before and it worked... however .. it is recommended that TerminateProcess() function oni be used when ExitProcess() function can't be used or won't responding............please advice.. ... THANK YOU :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.