在 Project → Options 設定 Appcalition → Title,在本例為 myApp。
procedure TfrmIsRunMain.FormCreate(Sender: TObject);
var
Mutex: HWND;
gt: Integer;
begin
Mutex := CreateMutex(nil,false,'myApp');
gt := GetLastError;
if (gt=Error_ALREADY_EXISTS) then
begin
ShowMessage('app is running!');
Application.Terminate;
end;
end;


沒有留言:
張貼留言