您的位置:首页 > 其它

控制只运行一份程序的另一个方法

2007-02-28 11:26 225 查看
将以下代码加到 工程文件中 即 .dpr 文件中

const iAtom='you exe name'; //如jzl

VAR
Mutex:THandle;
begin
Mutex:=CreateMutex(NIL,True,'you exe name');
IF GetLastError <> ERROR_ALREADY_EXISTS THEN
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end
else
MessageBox(0,'已经有一个程序在本机运行!','提示',mb_OK+MB_ICONINFORMATION);
ReleaseMutex(Mutex);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: