Одна копия приложения

14:21
unit Unique;
 
interface
 
uses
Windows, Sysutils;
 
implementation
 
var
UniqueName : string;
hMutex: THandle;
 
initialization
UniqueName := ExtractFileName(ParamStr(0));
hMutex := OpenMutex(MUTEX_ALL_ACCESS, false, pchar(UniqueName));
if hMutex <> 0 then
begin
CloseHandle(hMutex);
Halt;
end;
hMutex := CreateMutex(nil, false, pchar(UniqueName));
 
finalization
ReleaseMutex(hMutex);
end.