Solved

how to terminate a Delphi application?

Posted on 2000-05-09
8
4,357 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
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
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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…

679 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