阿杰 发表于 2012-3-11 10:37:15

检测是否重复运行

procedure Tfrmmain.FormCreate(Sender: TObject);
var FileName: string;
errNO: integer;
hMutex: HWND;
begin
hMutex := CreateMutex(nil, False, pchar(Application.title));
errNO := GetLastError;
if errNO = ERROR_ALREADY_EXISTS then begin //检测是否重复运行
    Application.MessageBox('软件已经在运行', '重复运行', MB_OK);
    Application.Terminate;
end
else
//...
end;

upring 发表于 2015-3-25 10:38:37

呵呵 互斥体检测也不错
页: [1]
查看完整版本: 检测是否重复运行