• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3487
  • Last Modified:

ExitCode for my application

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
sorentop
Asked:
sorentop
1 Solution
 
TOndrejCommented:
There's ExitCode variable declared in System unit for that purpose. Details in the help.
0
 
CynnaCommented:
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
 
CleanupPingCommented:
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
 
Lukasz LachCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now