Solved

how to terminate a Delphi application?

Posted on 2000-05-09
8
4,291 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now