I have the code line by line:
var
AppMutex: THandle;
{....}
initialization
// Create the mutex
AppMutex: = CreateMutex (nil, True, 'MY-APPLICATION-NAME');
if (AppMutex = 0) or (GetLastError = ERROR_ALREADY_EXISTS) then
begin
MessageDlg('My application is already running on this computer.'#13#10+
'You should close the other instance before starting a new one.',mtError,
[mbOK],0);
Halt;
end;
finalization
// Close the mutex
CloseHandle(AppMutex);
, , @mghie, /!
: , , .