Solved

how to terminate a Delphi application?

Posted on 2000-05-09
8
4,347 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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