Solved

how to terminate a Delphi application?

Posted on 2000-05-09
8
4,375 Views
Last Modified: 2012-06-27
How do I immediatly terminate a Delphi application in formCreate?
application.terminate does not immediatly termiantes an application.
0
Comment
Question by:jorge_c
[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
8 Comments
 
LVL 6

Expert Comment

by:edey
ID: 2793280
in an event driven system, nothing happens "immediatly", do you want to give the impression it does?

GL
Mike
0
 
LVL 1

Expert Comment

by:bcoleman
ID: 2793316
try 'halt'
0
 

Expert Comment

by:Dippen
ID: 2793344
Use a global boolean variable, for instance called RunApplication, and declare it publically in the main unit.
Then, in the formCreate, you set the variable to False if the application shouldn't be launched at all. Finally, somewhere in the project source (.dpr file), add the lines:

if not RunApplication then begin
  application.terminate;
  exit;
end;

The lines should be added somewhere after the Application.CreateForm statements and (important) before
the Application.Run statement!

Another solution is to move the code that does the checking from the formCreate method to the project source...

Hope this helps!

Regards, Daniel
0
Independent Software Vendors: 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!

 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 2793358
It's much easier! Simply call "ExitProcess(0)". This works always perfectly, regardless where you put it in your code...

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2793364
P.S: Halt works in some cases and in some not, I don't remember where it didn't work. Anyway, it doesn't matter, ExitProcess works always.
0
 

Author Comment

by:jorge_c
ID: 2793420
Thanks for all you answers. calling ExitProcess(0) works great for me.
Now, how do I give the points to Madshi?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2793480
First reject Dippen's answer. Then you can accept my comment as the answer.

Thank you...   :-)
0
 

Author Comment

by:jorge_c
ID: 2793491
calling ExitProcess(0) works better for me since I have to call it from different places in my code.
0

Featured Post

Industry Leaders: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 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