//加上 Windows单元
var hAppMutex: THandle; begin Application.Initialize; hAppMutex := CreateMutex(nil, false,'PaiWeiControl'); if (hAppMutex = 0) then begin MessageBox(0,'创建互斥对象失败!','Error',MB_OK + MB_ICONINFORMATION ); Exit; end; if ((hAppMutex <> 0) and (GetLastError() = ERROR_ALREADY_EXISTS)) then begin MessageBox(0,'只能运行一个相同程序!','Error',MB_OK + MB_ICONINFORMATION ); CloseHandle(hAppMutex); Exit; end; Application.CreateForm(Tlogout, logout); Application.Run; CloseHandle(hAppMutex); end.