![]() |
![]() ![]() ![]() |
acOnlyOne component.
|
procedure CloseFirstInstance;
|
The CloseFirstInstance method closes the previos instance of the application.
|
|
![]() |
|
However, if you would like to close ALL instances of your application when, for example, your program started with "/close" command-line parameter, you can use CloseFirstAppInstance procedure, exported from acOnlyOne unit, and use following code in the main ".DPR" unit of your program. This example demonstrates how to kill previous program instance and close itself without creating any forms:
|
|
program YourProgramName;
|
|
uses
|
acOnlyOne,
|
acUtils,
|
Main in 'Main.pas' {MainForm};
|
|
{$R *.RES}
|
|
begin
|
if HasParamStr('/close') then
|
begin
|
CloseFirstAppInstance;
|
Exit;
|
end;
|
|
Application.Initialize;
|
Application.Title := 'YourProgramTitle';
|
Application.CreateForm(TMainForm, MainForm);
|
Application.Run;
|
end.
|
|
![]() |
Usage of CloseApp.exe is following:
|
CloseApp.exe [ApplicationTitle]
|
For example:
|
CloseApp.exe MyAppTitle
|
CloseFirst and CloseSecond properties;
|
OnAlreadyExist event.
|