delphi代码
var
hMutex: Cardinal;
hMutex := CreateMutex(nil, False, PChar('Name'));
if (GetLastError = ERROR_ALREADY_EXIST) then
begin
CloseHandle(hMutex);
Exit;
end;
//do something
Application.Run;
CloseHandle(hMutex);
delphi代码
var
hMutex: Cardinal;
hMutex := CreateMutex(nil, False, PChar('Name'));
if (GetLastError = ERROR_ALREADY_EXIST) then
begin
CloseHandle(hMutex);
Exit;
end;
//do something
Application.Run;
CloseHandle(hMutex);