|
|
|
| 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 following code in the main ".DPR" unit of your program. The 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.
|
| CloseFirst and CloseSecond properties;
|
| OnAlreadyExist event.
|