function CheckSingleApp(): Boolean; var MutexHandler: HWND; Pid: HWND; begin result:= true; MutexHandler:= CreateMutex(nil, True,PWideChar(ExtractFileName(Application.ExeName))); if GetLastError= ERROR_ALREADY_EXISTS then begin ReleaseMutex(MutexHandler); Pid:= FindWindow(nil,PChar('WMS')); if Pid>0 then begin ShowWindow(Pid,SW_SHOWMAXIMIZED); end else begin Application.MessageBox(PChar('程序已打开,请勿重复打开.'),'提示',mb_ok+ MB_ICONWARNING); end; Application.Terminate; end; end; |
|