Solved

ExitCode for my application

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 151
When i run adoquery my application freezes 26 205
Delphi Seattle StructureView color 1 30
delphi popmenu non latine charcters 3 44
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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