//--------------------------------------------------------------------------- #pragma hdrstop #include "AppGlobalF.h" //--------------------------------------------------------------------------- #pragma package(smart_init) void ActiveProgram(String AClassName, String ATitle) { //String AClassName = "TFrmVmsFormEdit"; //String ATitle = g_AppCfg.sTitle + " - Active"; HWND hExeForm = FindWindow(AClassName.c_str(), ATitle.c_str()); if (hExeForm) { bool bResult = SetWindowPos(hExeForm, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); if (bResult) { bResult = ShowWindow(hExeForm, SW_RESTORE); SetForegroundWindow(hExeForm); } } } //--------------------------------------------------------------------------- bool ApplicationSingleRun(String AClassName, String ATitle) { HANDLE hMutex; try { String sLockFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".lock"); String sProgMutexNm = "ICAIR_" + sLockFile; if ((hMutex=OpenMutex(MUTEX_ALL_ACCESS, false, sProgMutexNm.c_str()))==NULL) hMutex = CreateMutex(NULL, true, sProgMutexNm.c_str()); else { ActiveProgram(AClassName, ATitle); return false; } } catch (Exception &exception) { Application->ShowException(&exception); return false; } return true; }