Solved

ExitCode for my application

Posted on 2002-06-28
4
3,232 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 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

15 Experts available now in Live!

Get 1:1 Help Now