Tricks to outsmart the application at the same time only one instance is allowed (run).
PrevInstance function (AppID: String): Boolean;
/ / Handle Applications When you first run ...
if WaitForSingleObject (CreateMutex (nil, False, PChar (AppID)), 0) <> wait_timeout then
Result: = False else Result: = True;
The function is similar to the function App.PrevInstance owned by Visual Basic. Add functionality to your project source (Select menu Project - View Source).
if PrevInstance ('X Project V.1') then
/ / Command if the application is Running ...
MessageBox (Application.Handle, 'Application Running!',
Application.Title: = 'X Project';
Application.CreateForm (TForm1, Form1);
For the AppID parameter, can be tailored to the wishes. For instance identifier of the application form of the name. Exe file it:
if PrevInstance (Application.ExeName) then / / etc .....
As proof: compile and try to run the program output (not to be terminated first) and then run it again.
Do not forget to add the clause uses the Windows unit.