Code: Select all
Mutex := CreateMutex(nil, True, 'app'); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
try
if (Application.ExeName = 'app.exe') and ((Mutex = 0) or (GetLastError = ERROR_ALREADY_EXISTS)) then
ShowMessage ('app is already running')
else
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end;
finally
ReleaseMutex(Mutex); <<<<<<<<<<<<<<<<<<<<<<<<
end;
Code: Select all
allocation number: 35332
program up time: 743 ms
type: Mutex Handle
handle: $99c
access rights: $1f0001
name: \Sessions\1\BaseNamedObjects\app
main thread ($a64):
671ccc16 madExcept32.dll madExceptDbg 3538 CreateMutexWCallback
00416df2 app.exe Winapi.Windows 35136 CreateMutex
01329f79 app.exe app 24 initialization
774e38f2 KERNEL32.DLL BaseThreadInitThunk
Thanks