Delphi/Lazarus: Close own Program
Question by Axuter | 2014-08-03 at 19:40
I would like to use a command within my Delphi or Lazarus application that is closing the program itself.
I know, this is very easy, if you only have a single Form (a simple "Close;" is sufficient in this case). If there are more than one Form, it is enough to close the main form (MainForm.Close; if MainForm ist the name of your main form).
However, in my case, this is not that easy, because closing the application should also work, if there is not yet created any Form at the moment, the command is executed. Are there still ways to handle the exit?
Related Topics
Delphi/Lazarus: Command Line Parameter Tutorial Part 1: Sending
Tutorial | 0 Comments
Delphi: Global Treatment of Errors (Exceptions)
Tutorial | 0 Comments
Delphi/Lazarus: 3 Ways to round a Number to X Decimal Places
Tutorial | 7 Comments
Delphi: System-Wide HotKey
Tutorial | 1 Comment
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Windows: How to run a Program as Administrator - Once, Always or with Shortcut
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
As you have correctly said, you can simply close any GUI application with:
If there is not any main form available, if you do not have a GUI application or if there are any other reasons why you would like to immediately shut your program, you can also use:
This automatically closes all forms/windows that are possibly opened.
Note: You have to include "Forms" into your "USES" section, to be able to access "Application".
Last update on 2021-04-07 | Created on 2014-08-04