//--------------------------------------------------------------------------- #include #pragma hdrstop USERES("Configuration_IFC.res"); USEFORM("W:\TexPrint\TpwTest\Config\Config_F.cpp", ConfigForm); USEUNIT("W:\TexPrint\TpwTest\ProtectCard.cpp"); USEUNIT("W:\TexPrint\TpwTest\Define.cpp"); //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { const char *mutexname[2] = { "TexpiaDesignCAD(TexPrint)", "TexpiaDesignCAD(Configuration)" }; AnsiString str[1]; HANDLE hMutex = NULL, hComp = NULL; str[0] = "TexPrint"; try { hMutex = OpenMutex(0, false, mutexname[1]); if (hMutex==NULL) { hMutex = CreateMutex(NULL, true, mutexname[1]); for (int i=0; i<1; i++) { hComp = OpenMutex(0, false, mutexname[i]); if (hComp) { CloseHandle(hComp); ShowMessage("After Close " + str[i] + " Application, try again!"); return 0; } } } else { CloseHandle(hMutex); ShowMessage("Application already running."); return 0; } Application->Initialize(); Application->Title = "TexPro Design CAD System Configuration"; Application->CreateForm(__classid(TConfigForm), &ConfigForm); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } ReleaseMutex(hMutex); CloseHandle(hMutex); return 0; } //---------------------------------------------------------------------------