Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ExitCode for my application

Posted on 2002-06-28
4
Medium Priority
?
3,443 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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