//用互斥mutex实现<br>var <br> Mutex: THandle; <br>begin <br> Mutex := CreateMutex(nil, True, '程序名字'); <br> try <br> if GetLastError = ERROR_ALREADY_EXISTS then <br> begin <br> MessageBox(0, '请不要重复运行本程序!', '警告', MB_OK); <br> Exit; <br> end <br> else <br> begin <br> Application.Initialize; <br> Application.CreateForm(TDBM, DBM); <br> Application.CreateForm(TfrmMain, frmMain); <br> Application.Run; <br> end; <br> finally <br> CloseHandle(Mutex); <br> end; <br>end.