Solved

hOw to provide exit code to ExitProcess()?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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