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

    技术2022-05-11  88

    将以下代码加到  工程文件中 即 .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);    


    最新回复(0)