{
关键字= 避免程序重复运行
采集软件=MKM - 我的知识管理
采集日期=2023-11-23 13:51:18
数字签名=837B4270090D43C17E77EB399FCDB1D8
}
uses
Winapi.Windows, Winapi.Messages, System.SysUtils,
System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Menus;
procedure Del; // 避免重复运行
var
Mutex: THandle;
begin
{ 避免重复运行}
Mutex := CreateMutex(nil, True, PChar(Application.Title));
if GetLastError = ERROR_ALREADY_EXISTS then
begin
Application.MessageBox('程序已经在运行 … ‘,’ 系统提示 ', MB_ICONERROR);
ReleaseMutex(Mutex); { 释放资源 }
Application.Terminate;
end;
end;