//--------------------------------------------------------------------------- #include #pragma hdrstop USEFORM("W:\TexStylist\TpwTest\Config\Config_F.cpp", ConfigForm); //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { const char mutexname[] = "TexStylistDesignCAD(Configuration)"; const char texstylistmutexname[] = "TexStylistDesignCAD"; HANDLE hMutex = NULL, hTexStylistMutex = NULL; OSVERSIONINFO strOSVersionInfo; strOSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); try { GetVersionEx(&strOSVersionInfo); if (strOSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) { hMutex = OpenMutex(SYNCHRONIZE, false, mutexname); } else { hMutex = OpenMutex(0, false, mutexname); } if (hMutex==NULL) { hMutex = CreateMutex(NULL, true, mutexname); if (strOSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) { hTexStylistMutex = OpenMutex(SYNCHRONIZE, false, texstylistmutexname); } else { hTexStylistMutex = OpenMutex(0, false, texstylistmutexname); } if (hTexStylistMutex) { ShowMessage("After Close TexStylist Application, try again!"); ReleaseMutex(hTexStylistMutex); ReleaseMutex(hMutex); CloseHandle(hMutex); return 0; } } else { ReleaseMutex(hMutex); ShowMessage("Application Already Running."); return 0; } Application->Initialize(); Application->Title = "TexStylist Design CAD System Configuration"; Application->CreateForm(__classid(TConfigForm), &ConfigForm); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } ReleaseMutex(hMutex); CloseHandle(hMutex); return 0; } //---------------------------------------------------------------------------