S3_Leo 发表于 2024-6-15 17:27:21

DELPHI 使程序只能运行一次


procedure TForm1.FormCreate(Sender: TObject);
var
errno:integer;
hmutex:hwnd;
begin
hmutex:=createmutex(nil,false,pchar(application.Title));
errno:=getlasterror;
if errno=error_already_exists then
begin
    ShowMessage('程序已经在运行了');
    Application.Terminate;
end;
end;
页: [1]
查看完整版本: DELPHI 使程序只能运行一次