//--------------------------------------------------------------------------- #include #pragma hdrstop //--------------------------------------------------------------------------- USEFORM("W:\TexWeave\TpwTest\Config\Config_F.cpp", ConfigForm); //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { const char mutexname[] = "TexWeaveDesignCAD(Configuration)"; const char texweavemutexname[] = "TexWeaveDesignCAD"; HANDLE hMutex = NULL, hTexWeaveMutex = 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) { hTexWeaveMutex = OpenMutex(SYNCHRONIZE, false, texweavemutexname); } else { hTexWeaveMutex = OpenMutex(0, false, texweavemutexname); } if (hTexWeaveMutex) { ShowMessage("After Close TexWeave Application, try again!"); ReleaseMutex(hTexWeaveMutex); ReleaseMutex(hMutex); CloseHandle(hMutex); return 0; } } else { ReleaseMutex(hMutex); ShowMessage("Application Already Running."); return 0; } Application->Initialize(); Application->Title = "TexWeave 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; } //---------------------------------------------------------------------------