Solved

ExitCode for my application

Posted on 2002-06-28
4
3,198 Views
Last Modified: 2012-05-05
Hi

How do I set the exitcode of my delphi application when it terminates.
I know I could use halt(exitcode), but halt is only used with abnormal termination.

If I call ExitProcess(exitcode) will my delphi application be shutdown properly ?
0
Comment
Question by:sorentop
4 Comments
 
LVL 8

Expert Comment

by:TOndrej
ID: 7115854
There's ExitCode variable declared in System unit for that purpose. Details in the help.
0
 
LVL 7

Accepted Solution

by:
Cynna earned 100 total points
ID: 7118671
sorentop,

You sould exit your app using Form1.Close (assume Form1 is
your main form). This is the *proper* way of doing it.
Alternative is using Application.Terminate. This is also
quite safe, but, in this case OnCloseQuery and OnClose will
not fire. In both cases OnDestroy event will fire.
Before you call Form1.Close or Application.Terminate, set
System.ExitCode var to desired value.

Example (Exit app with exit code):
----------------------------------------------------------

  // The proper way:
  System.ExitCode:=1; Form1.Close;

or

  // Also OK, but read above remarks:
  System.ExitCode:=1; Application.Terminate;




> If I call ExitProcess(exitcode) will my delphi application be shutdown properly ?

Not always. It stops the process without calling unit
finalization , and leaves many libraries and resource
locks unreleased. In most cases, you should avoid it.
0
 

Expert Comment

by:CleanupPing
ID: 9343139
sorentop:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 9454077
sorentop,
No comment has been added lately (17 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to Cynna http:#7118671

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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