Solved

hOw to provide exit code to ExitProcess()?

Posted on 2004-08-11
4
932 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 100 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now