void TConfDlg::SaveConfig(const AnsiString &File) { HANDLE file; DWORD type,Written; int i; CHostRef *host; AnsiString FailedName="NONE"; file = CreateFileA(File.c_str(),GENERIC_WRITE,0,0,CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN,0); if(file == INVALID_HANDLE_VALUE) { Application->MessageBox("Cannot create file!","Error",MB_OK|MB_ICONERROR); return; } // Remove the configuration from hosts // That do not have an individual configuration for(i =0;i<LastList->Count;++i) { host = (CHostRef*)(LastList->Objects[i]); if(host) host->RemoveConfigRefs(); } FailedName="MAGIC"; type = MAGIC; if(!WriteFile(file,&type,sizeof(DWORD),&Written,0)) goto Remove; FailedName="FILE_VERSION"; type = FILE_VERSION; if(!WriteFile(file,&type,sizeof(DWORD),&Written,0)) goto Remove; FailedName="Plugin"; if(!WritePlugin(file,PluginManager.GetActualPlugin())) goto Remove; FailedName = "WriteConfigData"; if(!WriteConfigData(file,&GlobalConfig)) goto Remove; FailedName="WriteHost"; for(i=0;i<LastList->Count;++i) { if(!WriteHost(file,(HostData*)*(CHostRef*)LastList->Objects[i])) goto Remove; } //SI: 13.06.05 Write Account at last position //SI: 14.06.05 save without Write Account possible FailedName="WriteAccount"; //if(!WriteAccount(file,&GlobalConfig)) goto Remove; if(!WriteAccount(file,&GlobalConfig)) Application->MessageBox("Could not save account information in config!","Error",MB_ICONERROR|MB_OK);; type = TYPE_NONE; WriteFile(file,&type,sizeof(DWORD),&Written,0); CloseHandle(file); for(i=0;i<LastList->Count;++i) { host=(CHostRef*)LastList->Objects[i]; // If the host has no individual configuration then // set a reference to the global config. host->SetConfigRef(&GlobalConfig); } return; Remove: CloseHandle(file); DeleteFileA(File.c_str()); FailedName = FailedName + " failed. Could not save config!"; Application->MessageBox(FailedName.c_str(),"Error",MB_ICONERROR|MB_OK); return; }
VOID _cdecl Main( WORD NumArgs, CHAR *Args[], CHAR *EnvStrings[] ) { MSG Msg; WORD Key; CHAR FileName[65]; CHAR PrinterPort[65]; HFILE TMSBegrFile; HFILE TMSAbtFile; HFILE TMSZKontFile; DWORD EffTime; WinInitialize( MAXNUMWINDOWS ); WinCreateWindow( Desktop, &Desktop, NULL, 0, 0, 0, 0, 0, 0 ); WinHideCursor(); WinColor( Desktop, NORMAL, 0, 0, WinGetx2( Desktop ), WinGety2( Desktop ) ); WinCreateWindow( Desktop, &Bottomline, BottomlineProc, 0, 0, BOTTOMLINEX1, BOTTOMLINEY1, BOTTOMLINEX2, BOTTOMLINEY2 ); if( !ReadConfigData() ) { static struct HelpKey HelpKeys[NUMLAUFWERKHELPKEYS] = { { 0, 0, "</> Wert erh�hen/erniedrigen" }, { 0, 1, "<Enter> Wert akzeptieren" }, { 40, 1, "<Esc> Programm verlassen" } }; HWND TMSLaufwerk; BOOL LaufwerkOK; WinFill( Desktop, '�', 0, 22, 79, 22 ); InitConfigData(); WinString( Desktop, "TMS Laufwerk", CENTER, 0, 7 ); WinString( Desktop, "������������", CENTER, 0, 8 ); WinColor( Desktop, HIGHLIGHT, 33, 7, 46, 7 ); WinCreateWindow( Desktop, &TMSLaufwerk, TMSLaufWerkProc, 0, 0, 37, 10, 40, 10 ); WinString( Desktop, "Geben Sie bitte an, in welchem Laufwerk sich TMS befindet.", CENTER, 0, 14 ); WinSendMsg( Bottomline, WM_HELP, (WORD)&HelpKeys, NUMLAUFWERKHELPKEYS ); WinSendMsg( TMSLaufwerk, WM_SHOW, 0, 0 ); WinSendMsg( TMSLaufwerk, WM_SETFOCUS, 0, 0 ); do { LaufwerkOK = TRUE; do { Key = BiosGetKey(); Msg = WinSendMsg( TMSLaufwerk, WM_CHAR, (MPARAM)Key, 0 ); } while( (WORD)Msg != KBENTER && (WORD)Msg != KBESC ); if( (WORD)Msg == KBESC ) { DosFreeFarMem( ConfigData ); WinDestroyWindow( TMSLaufwerk ); WinDestroyWindow( Bottomline ); WinDestroyWindow( Desktop ); return; } if( !OpenPathFile() ) { LaufwerkOK = FALSE; } } while( !LaufwerkOK ); ClosePathFile(); WinDestroyWindow( TMSLaufwerk ); WinColor( Desktop, NORMAL, 0, 0, WinGetx2( Desktop ), 21 ); WinFill( Desktop, SPACECHAR, 0, 0, WinGetx2( Desktop ), WinGety2( Desktop ) ); } switch( NumArgs ) { case 2: StdStrLwr( Args[1] ); if( StdStrCmp( Args[1], "exportfile" ) == 0 || StdStrCmp( Args[1], "export" ) == 0 ) { WinFill( Desktop, '�', 0, 22, 79, 22 ); ExportFileConversion(); } else { ; // Debug!!!! } break; case 1: if( !OpenPathFile() ) ; // Debug!!!!! ReadPathFileEntry( TMSBEGRUENDNO, FileName, FALSE ); DosOpen( FileName, &TMSBegrFile, OPEN_RDONLY ); DosLastModTime( TMSBegrFile, &EffTime ); if( ConfigData->TMSBegruendungsDatum != EffTime ) { if( !CreateList( TMSBegrFile, BEGRUENDUNGEN ) ) { WinString( Desktop, "In TMS sind 0 Begr�ndungen verzeichnet!", LEFT, 0, 0 ); return; // Debug-Version!!!!! } SortList( BEGRUENDUNGEN ); ConfigData->TMSBegruendungsDatum = EffTime; StdFarMemSet( ConfigData->BegrCheckListe, TRUE, sizeof( ConfigData->BegrCheckListe ) ); } DosClose( TMSBegrFile ); ReadPathFileEntry( TMSABTEILNO, FileName, FALSE ); DosOpen( FileName, &TMSAbtFile, OPEN_RDONLY ); DosLastModTime( TMSAbtFile, &EffTime ); if( ConfigData->TMSAbteilungsDatum != EffTime ) { if( !CreateList( TMSAbtFile, ABTEILUNGEN ) ) { WinString( Desktop, "In TMS sind 0 Abteilungen verzeichnet!", LEFT, 0, 0 ); return; // Debug-Version!!!!! } SortList( ABTEILUNGEN ); ConfigData->TMSAbteilungsDatum = EffTime; StdFarMemSet( ConfigData->AbtCheckListe, TRUE, sizeof( ConfigData->AbtCheckListe ) ); } DosClose( TMSAbtFile ); ReadPathFileEntry( TMSZEITKNO, FileName, FALSE ); DosOpen( FileName, &TMSZKontFile, OPEN_RDONLY ); DosLastModTime( TMSZKontFile, &EffTime ); if( ConfigData->TMSZeitKontiDatum != EffTime ) { if( !CreateList( TMSZKontFile, ZEITKONTI ) ) { WinString( Desktop, "In TMS sind 0 Zeitkonti verzeichnet!", LEFT, 0, 0 ); return; // Debug-Version!!!!! } // SortList( ZEITKONTI ); ConfigData->TMSZeitKontiDatum = EffTime; StdFarMemSet( ConfigData->ZKontCheckListe, TRUE, sizeof( ConfigData->ZKontCheckListe ) ); } DosClose( TMSZKontFile ); ReadPathFileEntry( TMSPRINTERINFONO, FileName, FALSE ); ReadPathFileEntry( TMSPRINTERPORTNO, PrinterPort, TRUE ); GetPrinterInfo( FileName, PrinterPort ); ClosePathFile(); LoadList( BEGRUENDUNGEN ); LoadList( ABTEILUNGEN ); LoadList( ZEITKONTI ); WinString( Desktop, "������������������������������������Ŀ", CENTER, 0, 3 ); WinString( Desktop, "� �", CENTER, 0, 4 ); WinString( Desktop, "� Statistik - Generierung �", CENTER, 0, 5 ); WinString( Desktop, "� ����������������������� �", CENTER, 0, 6 ); WinString( Desktop, "� und �", CENTER, 0, 7 ); WinString( Desktop, "� ��� �", CENTER, 0, 8 ); WinString( Desktop, "� Verwaltung der Exportdaten �", CENTER, 0, 9 ); WinString( Desktop, "� �������������������������� �", CENTER, 0, 10 ); WinString( Desktop, "� �", CENTER, 0, 11 ); WinString( Desktop, "� von TMS �", CENTER, 0, 12 ); WinString( Desktop, "� �", CENTER, 0, 13 ); WinString( Desktop, "��������������������������������������", CENTER, 0, 14 ); WinString( Desktop, " (c) Copyright 1992, 1993 J.Skripsky ", CENTER, 0, 16 ); WinString( Desktop, " Designed and Developed by ", CENTER, 0, 18 ); WinString( Desktop, " Juraj Skripsky ", CENTER, 0, 19 ); WinString( Desktop, " CH-8952 Schlieren ", CENTER, 0, 20 ); BiosGetKey(); WinFill( Desktop, SPACECHAR, 0, 0, WinGetx2( Desktop ), WinGety2( Desktop ) ); WinFill( Desktop, '�', 0, 22, 79, 22 ); WinFill( Desktop, '�', 27, 0, 27, 21 ); WinFill( Desktop, '�', 0, 22, 79, 22 ); WinCreateWindow( Desktop, &Menu, MenuProc, 0, 0, 1, 1, 25, 20 ); WinSendMsg( Menu, WM_SHOW, 0, 0 ); WinSendMsg( Menu, WM_SETFOCUS, 0, 0 ); do { Key = BiosGetKey(); Msg = WinSendMsg( Menu, WM_CHAR, (MPARAM)Key, 0 ); } while( (WORD)Msg != KBESC ); FreeList( BEGRUENDUNGEN ); FreeList( ABTEILUNGEN ); FreeList( ZEITKONTI ); FreePrinterInfo(); WinDestroyWindow( Menu ); break; } if( !WriteConfigData() ) ; // Debug!!!!! WinDestroyWindow( Bottomline ); WinDestroyWindow( Desktop ); WinTerminate(); }