?
Solved

hOw to provide exit code to ExitProcess()?

Posted on 2004-08-11
4
Medium Priority
?
946 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

719 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