Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

hOw to provide exit code to ExitProcess()?

Posted on 2004-08-11
4
Medium Priority
?
948 Views
Last Modified: 2013-12-03
Hi,  
    I have created a process using
               
          CreateProcess(,,,,,);

    I will terminate the Process by calling

          ExitProcess(fuExitCode);

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



0
Comment
Question by:maxemillion_max
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:alikoank
ID: 11771083
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:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/exitprocess.asp
0
 

Author Comment

by:maxemillion_max
ID: 11771164
actually i have come to that link already... thanks you..
0
 

Author Comment

by:maxemillion_max
ID: 11771208
:) 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 :)
0
 
LVL 4

Accepted Solution

by:
alikoank earned 400 total points
ID: 11771258
OK.

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.

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

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


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question