用互斥的办法是最好的啦。<br>先在全局变量单元里面定义: hMutex: Boolean;<br><br>var<br> Res: DWORD;<br> Wnd: HWND;<br><br>begin<br> Application.Initialize;<br> hMutex := CreateMutex(nil, False, Title);<br> try<br> Res := GetLastError;<br> if Res <> ERROR_ALREADY_EXISTS then begin<br> Application.Initialize;<br> Application.Title := '登录';<br><br><br> frmLogon := TfrmLogon.Create(Application);<br> try<br> if Not frmLogon.AutoLogon then<br> begin<br> if frmLogon.ShowModal <> mrOk then Exit;<br> end;<br> LogonID := frmLogon.LogonID;<br> LogonName := frmLogon.LogonName;<br> LogonUser := frmLogon.LogonUser;<br> LogonIP := GetIPAddress;<br> finally<br> frmLogon.Free;<br> end;<br> Application.CreateForm(TfrmMain, frmMain);<br> Application.HintPause := 10;<br> Application.HintHidePause := 120000;<br> Application.Run;<br> end else begin<br> Wnd := FindWindow('TApplication', PChar(Title));<br> if Wnd <> 0 then<br> SendMessage(Wnd, WM_SYSCOMMAND, SC_RESTORE, 0);<br> Application.MessageBox('系统已经在运行!', '启动失败',<br> MB_ICONEXCLAMATION);<br> end;<br> finally<br> ReleaseMutex(hMutex);<br> end;<br><br>end.