// iniFile.cpp: implementation of the CiniFile class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "iniFile.h" #include "colors.h" // debug symbols and memory leak detection #ifdef _DEBUG extern void __cdecl operator delete(void *pvMem); extern void* operator new (unsigned int s, unsigned short* name, int line); #define delete ::delete #define new ::new(_T(__FILE__), __LINE__) #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// Section::Section() { m_csSectionName = ""; bIsEmpty = 1; CstKey = NULL; } ////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////// stKey::stKey() { csKey=NULL; csValue=NULL; } ////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////// stKey::stKey(stKey &s) { csKey = s.csKey; csValue = s.csValue; } ////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////// stKey::stKey(stKey *s) { csKey = s->csKey; csValue = s->csValue; } ////////////////////////////////////////////////////////////////////// // Destruction ////////////////////////////////////////////////////////////////////// stKey::~stKey() { if(csKey != NULL) { delete []csKey; csKey=NULL; } if(csValue !=NULL) { delete []csValue; csValue=NULL; } } ////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////// Section::Section( Section &s ) { //prebehnutie celej sekcie m_csSectionName = s.m_csSectionName; bIsEmpty = s.bIsEmpty; } ////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////// Section::Section( Section *s ) { m_csSectionName = s->m_csSectionName; bIsEmpty = s->bIsEmpty; CstKey=s->CstKey; } ////////////////////////////////////////////////////////////////////// // set 1 ////////////////////////////////////////////////////////////////////// void Section::SetEmty() { bIsEmpty = 1; } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CiniFile::CiniFile() { m_pfdIni = NULL; pcFileName = NULL; sAktSection=NULL; bDalsia = FALSE; bDalsia=FALSE; m_bWriteSection=false; m_bReadSection=false; m_maxCount =0; } CiniFile::~CiniFile() { if(pcFileName != NULL ) { delete []pcFileName; } } ////////////////////////////////////////////////////////////////////// // InitializeFile: nacitanie udajov zo suboru ////////////////////////////////////////////////////////////////////// bool CiniFile::InitializeFile(char * pcFileName) { FILE *stream=NULL; if((stream=fopen(pcFileName,"r")) != NULL) { ReadIniFile(stream); fclose(stream); return true; } else { MessageBox(GetActiveWindow(), L"Ini File Not Found!", L"Message", MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); return false; } } ////////////////////////////////////////////////////////////////////// // ReadIniFile: nacitanie udajov zo suboru ////////////////////////////////////////////////////////////////////// void CiniFile::ReadIniFile(FILE *fd) { int iLenght = 1024; char *pLine = new char[1024]; while (fgets(pLine,iLenght,fd) != NULL) { ParseLine(pLine); } //vlozenie poslednej naplnenej sekcie do zoznamu if(sAktSection != NULL) { sAktSection->CstKey->FillArray(); m_clsSection.AddTail(sAktSection); } delete pLine; } ////////////////////////////////////////////////////////////////////// // ParseLine: vytvorenie sekcie + ulozenie dat zo suboru do struktur ////////////////////////////////////////////////////////////////////// void CiniFile::ParseLine(char *pLine) { int iFind=-1; int iFindL=-1; int iFindR=-1; CString cLine(pLine); CString cLeft; CString cRight; wchar_t *wTemp; wchar_t *wKey; wchar_t *wValue; //ak je to komentar preskoc ho iFind =cLine.Find(L";"); if(iFind == -1) { iFindL=cLine.Find(L"["); iFindR=cLine.Find(L"]"); //ak je to sekcia vytvor ju if((iFindL !=-1) && (iFindR !=-1)) { cLine = cLine.Mid(iFindL,iFindR+1); //ulozenie do zoznamu sekcii if(sAktSection == NULL) { NewSection(cLine); bDalsia =TRUE; } else { //koli tomu ze niesu premenne referencovane tak musim hodit napleny list do listu sekcii if(bDalsia == TRUE) { sAktSection->CstKey->FillArray(); AddSection(sAktSection); NewSection(cLine); } } } else { //ak je to kluc = hodnota vloz ju do aktualnej sekcie iFind=cLine.Find(L"="); if(iFind != -1) { cLeft=cLine.Left(iFind); cRight=cLine.Right(cLine.GetLength()-iFind-1); cRight.TrimRight('\n'); //ukladanie do zoznamu sekcie kluc = hodnota //////opty wTemp = new wchar_t[cLeft.GetLength()+2]; ConvertCsToWc(cLeft,wTemp,cLeft.GetLength()/2); wKey=wTemp; wTemp = new wchar_t[cRight.GetLength()+2]; ConvertCsToWc(cRight,wTemp,cRight.GetLength()/2); wValue=wTemp; sAktSection->CstKey->AddString(wKey,wValue); //////endof opty } } } } ////////////////////////////////////////////////////////////////////// // CiniFile: vytvorenie novej sekcie v tvare [sekcia] ////////////////////////////////////////////////////////////////////// Section * CiniFile::NewSection(CString csName) { Section *sSection = new Section(); sSection->CstKey = new ClocalizationStrings(); sSection->m_csSectionName = csName; sAktSection = sSection; return sSection; } ////////////////////////////////////////////////////////////////////// // WriteProfileSection: vytvorenie novej sekcie v tvare [sekcia] alebo jej prepisanie ////////////////////////////////////////////////////////////////////// void CiniFile::WriteProfileSection(wchar_t *pcSectionName) { CString csSectName(pcSectionName); int pIndex; Section *scSection; scSection=GetSection(pcSectionName,&pIndex); if(csSectName.IsEmpty() == 1) { csSectName =L"[" + csSectName + L"]"; AddSection(NewSection(csSectName)); } else { RemoveSection(&pIndex); AddSection(scSection); } } ////////////////////////////////////////////////////////////////////// // AddSection: vlozenie novej sekcie do zoznamu ////////////////////////////////////////////////////////////////////// void CiniFile::AddSection(Section *psSection) { psSection->bIsEmpty=0; m_clsSection.AddTail(psSection); } /* ////////////////////////////////////////////////////////////////////// // AddSection: vlozenie novej sekcie do zoznamu ////////////////////////////////////////////////////////////////////// void CiniFile::AddSection(Section psSection) { psSection.bIsEmpty=0; m_clsSection.AddTail(psSection); } */ ////////////////////////////////////////////////////////////////////// // WriteProfileString: vlozenie noveho zaznamu do sekcie alebo jeho prepisanie ////////////////////////////////////////////////////////////////////// void CiniFile::WriteProfileString(wchar_t *pcSectionName, wchar_t *pcKey, wchar_t *pcValue) { wchar_t *wKey,*wValue; Section *scSection; int pIndex; int iInd =-1; CString csSectName; if(m_bWriteSection == false) { scSection = GetSection(pcSectionName,&pIndex); if(scSection->IsEmpty() ==1) { //sekcia [] csSectName = L"["; csSectName += pcSectionName; csSectName += L"]"; NewSection(csSectName); //////opty wKey= new wchar_t[wcslen(pcKey)+2]; wValue= new wchar_t[wcslen(pcValue)+2]; wcscpy(wKey,pcKey); wcscpy(wValue,pcValue); sAktSection->CstKey->AddStringFill(wKey,wValue); //////endof opty AddSection(sAktSection); } else { //do riesit RemoveSection(&pIndex); //ak ho nezmazal tak ide o novy prvok if(!RemoveIfExist(scSection,pcKey,pcValue)) { //////opty wKey= new wchar_t[wcslen(pcKey)+2]; wValue= new wchar_t[wcslen(pcValue)+2]; wcscpy(wKey,pcKey); wcscpy(wValue,pcValue); scSection->CstKey->AddStringFill(wKey,wValue); //////endof opty } AddSection(scSection); } } else { //////opty wKey= new wchar_t[wcslen(pcKey)+2]; wValue= new wchar_t[wcslen(pcValue)+2]; wcscpy(wKey,pcKey); wcscpy(wValue,pcValue); sAktSection->CstKey->AddStringFill(wKey,wValue); //////endof opty } } ////////////////////////////////////////////////////////////////////// // GetSection: varatenie pointra na sekciu ////////////////////////////////////////////////////////////////////// Section *CiniFile::GetSection(wchar_t *pcSectionName,int *pIndex) { BOOL bFind=FALSE; Section *scSection = new Section(); CString csSectName(pcSectionName); csSectName =L"[" + csSectName + L"]"; //Find a specific element. for (int i=0;(i < m_clsSection.GetCount()) && (bFind != TRUE);i++) { //koli kopirovaciemu kostruktoru je to takto! nemenit!!!! *scSection = m_clsSection.GetAt(m_clsSection.FindIndex(i)); if(scSection->m_csSectionName.Compare(csSectName) == 0) { bFind = TRUE; *pIndex = i; } } if(bFind==TRUE) { scSection->bIsEmpty=0; } else { scSection->SetEmty(); } return scSection; } ////////////////////////////////////////////////////////////////////// // RemoveSection: vymazanie sekcie ////////////////////////////////////////////////////////////////////// BOOL CiniFile::RemoveSection(int * iIndex) { m_clsSection.RemoveAt(m_clsSection.FindIndex(*iIndex)); return TRUE; } ////////////////////////////////////////////////////////////////////// // WriteProfileInt: zapisanie cisla do sekcie kluc=hodnota ////////////////////////////////////////////////////////////////////// void CiniFile::WriteProfileInt(wchar_t *pcSectionName, wchar_t *pcKey, int iValue) { //alokacia potom vyhodit wchar_t *buffer=new wchar_t[200]; int iCount; iCount = swprintf( buffer,L"%d", iValue ); WriteProfileString(pcSectionName, pcKey, buffer); delete [] buffer; } ////////////////////////////////////////////////////////////////////// // GetProfileString: varetenie stringu k hodnote kluca ////////////////////////////////////////////////////////////////////// void CiniFile::GetProfileString(wchar_t *pcSectionName, wchar_t *pcKey,wchar_t *Dest,int maxLen) { BOOL bEmty=FALSE; Section *scSection; int pIndex; scSection = GetSection(pcSectionName,&pIndex); if(scSection->IsEmpty() != 1) { GetString(scSection,pcKey,Dest,maxLen); } else { *Dest = NULL; } } ////////////////////////////////////////////////////////////////////// // GetString: varetenie stringu k hodnote kluca ////////////////////////////////////////////////////////////////////// void CiniFile::GetString(Section *sSection,wchar_t *pcKey,wchar_t *Dest,int maxLen) { BOOL bFind = FALSE; /////opty //-- NOT FOUND -- wcscpy(Dest,sSection->CstKey->GetLocalStringV(pcKey)); if(wcscmp(Dest,L"N") == 0) { *Dest=NULL; } ///// } ////////////////////////////////////////////////////////////////////// // GetProfileInt: varetenie intu k hodnote kluca ////////////////////////////////////////////////////////////////////// int CiniFile::GetProfileInt(wchar_t *pcSectionName, wchar_t *pcKey,wchar_t *Dest,int maxLen, bool *found) { int iNumber=0; GetProfileString(pcSectionName,pcKey,Dest,maxLen); if (*Dest != NULL) { iNumber=_wtoi(Dest); if (found) *found = true; } else { if (found) *found = false; } return iNumber; } ////////////////////////////////////////////////////////////////////// // SaveFile: zapis do IniFile ////////////////////////////////////////////////////////////////////// void CiniFile::SaveFile(char *pcFileName) { FILE *stream=NULL; if((stream=fopen(pcFileName,"w")) != NULL) { WriteIniFile(stream); fclose(stream); } else { MessageBox(GetActiveWindow(), L"Ini File Can't Created!", L"Message", MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); } } ////////////////////////////////////////////////////////////////////// // WriteIniFile: zapis do IniFile ////////////////////////////////////////////////////////////////////// void CiniFile::WriteIniFile(FILE *stream) { for (int i=0;i CstKey->GetCount(); ConvertCsToWc(sSection->m_csSectionName, temp, 1024); fwprintf( stream,L"%c%s%c%c",'\n',temp,'\n','\n'); for (int i=0;i < sCount;i++) { sData=sSection->CstKey->GetNextStrings(i); fwprintf( stream, L"%s=", sData->key), fwprintf( stream,L"%s\n", sData->localString); } } ////////////////////////////////////////////////////////////////////// // RemoveIfExist: vymazanie sekcie ako existuje ////////////////////////////////////////////////////////////////////// bool CiniFile::RemoveIfExist(Section *scSection, wchar_t *csKey,wchar_t *csValue) { bool bFind = false; bFind= scSection->CstKey->ReplaceIfExist(csKey,csValue); return bFind; } ////////////////////////////////////////////////////////////////////// // SaveDefaults: ulozenie defualtnych hodnot do ini suboru ////////////////////////////////////////////////////////////////////// void CiniFile::SaveDefaults(char *pcFilename) { CWaitCursor wait; WriteProfileString(L"backup",L"BackupPath",_T(BACKUPPATH)); WriteProfileInt(L"Synchronisation",L"ServerCount",1); WriteProfileString(L"Synchronisation",L"IP0",_T(MIP1)); WriteProfileString(L"Synchronisation",L"PORT0",_T(MPORT1)); WriteProfileString(L"Synchronisation",L"LoginName",L""); WriteProfileInt(L"Synchronisation",L"ID",0); WriteProfileInt(L"Synchronisation",L"LastSynchDay",0); WriteProfileInt(L"Synchronisation",L"LastSynchMonth",0); WriteProfileInt(L"Synchronisation",L"LastSynchYear",0); WriteProfileInt(L"Options",L"Printing",0); WriteProfileInt(L"Options",L"AutoSip",0); WriteProfileInt(L"Options",L"AutoFocusEdit",0); WriteProfileString(L"Language",L"Lang",L"EN"); SaveColors(); SaveFile(pcFilename); } ////////////////////////////////////////////////////////////////////// // CompPortId: skladanie mena portu s podfixom index v tvare PORT1 ////////////////////////////////////////////////////////////////////// void CiniFile::CompPortId(int iIndex,wchar_t *Dest, int maxLen) { swprintf(Dest,L"PORT%d", iIndex); } ////////////////////////////////////////////////////////////////////// // CompPortId: skladanie mena portu s podfixom index v tvare PORT1 postfix ////////////////////////////////////////////////////////////////////// void CiniFile::CompPortIp(int iIndex,wchar_t *Dest, int maxLen) { swprintf(Dest,L"IP%d", iIndex); } ////////////////////////////////////////////////////////////////////// // CompBox: skladanie mena Comboboxu_iIndex postfix ////////////////////////////////////////////////////////////////////// void CiniFile::CompBox(int iIndex1, int iIndex2,wchar_t *Dest, int maxLen) { swprintf(Dest,L"ComboBox_%d_%d", iIndex1,iIndex2); } ////////////////////////////////////////////////////////////////////// // CompBox: skladanie mena Comboboxu_iIndex postfix ////////////////////////////////////////////////////////////////////// void CiniFile::CompBox(int iIndex1,wchar_t *Dest, int maxLen) { swprintf(Dest,L"ComboBox_%d", iIndex1); } ////////////////////////////////////////////////////////////////////// // CompColuNameCount: prefix "Name"_Count ////////////////////////////////////////////////////////////////////// void CiniFile::CompColuNameCount(wchar_t *sName,wchar_t *Dest, int maxLen) { swprintf(Dest,L"%s%d_Count",sName); } ////////////////////////////////////////////////////////////////////// // CompColuNameWidth: prefix "Name"_Width_"width" postfix ////////////////////////////////////////////////////////////////////// void CiniFile::CompColuNameWidth(wchar_t *sName, int iIndex,wchar_t *Dest, int maxLen) { swprintf(Dest,L"%s_Width_%d",sName,iIndex); } ////////////////////////////////////////////////////////////////////// // CompColuNameWidth: prefix "Name"__Position_"width" postfix ////////////////////////////////////////////////////////////////////// void CiniFile::CompColuNamePosition(wchar_t *sName, int iIndex,wchar_t *Dest, int maxLen) { swprintf(Dest,L"%s_Position_%d",sName,iIndex); } ////////////////////////////////////////////////////////////////////// // SaveColors: ulozenie zakladnych nastaveni farieb ////////////////////////////////////////////////////////////////////// void CiniFile::SaveColors() { //zrychleny zapis SartWriteSetcion(L"Colors"); WriteProfileInt(L"Colors",L"ColorCount",33); WriteProfileInt(L"Colors",L"Color1_R",D_Color1_R); WriteProfileInt(L"Colors",L"Color1_G",D_Color1_G); WriteProfileInt(L"Colors",L"Color1_B",D_Color1_B); WriteProfileInt(L"Colors",L"Color2_R",D_Color2_R); WriteProfileInt(L"Colors",L"Color2_G",D_Color2_G); WriteProfileInt(L"Colors",L"Color2_B",D_Color2_B); WriteProfileInt(L"Colors",L"Color3_R",D_Color3_R); WriteProfileInt(L"Colors",L"Color3_G",D_Color3_G); WriteProfileInt(L"Colors",L"Color3_B",D_Color3_B); WriteProfileInt(L"Colors",L"Color4_R",D_Color4_R); WriteProfileInt(L"Colors",L"Color4_G",D_Color4_G); WriteProfileInt(L"Colors",L"Color4_B",D_Color4_B); WriteProfileInt(L"Colors",L"Color5_R",D_Color5_R); WriteProfileInt(L"Colors",L"Color5_G",D_Color5_G); WriteProfileInt(L"Colors",L"Color5_B",D_Color5_B); WriteProfileInt(L"Colors",L"Color6_R",D_Color6_R); WriteProfileInt(L"Colors",L"Color6_G",D_Color6_G); WriteProfileInt(L"Colors",L"Color6_B",D_Color6_B); WriteProfileInt(L"Colors",L"Color7_R",D_Color7_R); WriteProfileInt(L"Colors",L"Color7_G",D_Color7_G); WriteProfileInt(L"Colors",L"Color7_B",D_Color7_B); WriteProfileInt(L"Colors",L"Color8_R",D_Color8_R); WriteProfileInt(L"Colors",L"Color8_G",D_Color8_G); WriteProfileInt(L"Colors",L"Color8_B",D_Color8_B); WriteProfileInt(L"Colors",L"Color9_R",D_Color9_R); WriteProfileInt(L"Colors",L"Color9_G",D_Color9_G); WriteProfileInt(L"Colors",L"Color9_B",D_Color9_B); WriteProfileInt(L"Colors",L"Color10_R",D_Color10_R); WriteProfileInt(L"Colors",L"Color10_G",D_Color10_G); WriteProfileInt(L"Colors",L"Color10_B",D_Color10_B); WriteProfileInt(L"Colors",L"Color11_R",D_Color11_R); WriteProfileInt(L"Colors",L"Color11_G",D_Color11_G); WriteProfileInt(L"Colors",L"Color11_B",D_Color11_B); WriteProfileInt(L"Colors",L"Color12_R",D_Color12_R); WriteProfileInt(L"Colors",L"Color12_G",D_Color12_G); WriteProfileInt(L"Colors",L"Color12_B",D_Color12_B); WriteProfileInt(L"Colors",L"Color13_R",D_Color13_R); WriteProfileInt(L"Colors",L"Color13_G",D_Color13_G); WriteProfileInt(L"Colors",L"Color13_B",D_Color13_B); WriteProfileInt(L"Colors",L"Color14_R",D_Color14_R); WriteProfileInt(L"Colors",L"Color14_G",D_Color14_G); WriteProfileInt(L"Colors",L"Color14_B",D_Color14_B); WriteProfileInt(L"Colors",L"Color15_R",D_Color15_R); WriteProfileInt(L"Colors",L"Color15_G",D_Color15_G); WriteProfileInt(L"Colors",L"Color15_B",D_Color15_B); WriteProfileInt(L"Colors",L"Color16_R",D_Color16_R); WriteProfileInt(L"Colors",L"Color16_G",D_Color16_G); WriteProfileInt(L"Colors",L"Color16_B",D_Color16_B); WriteProfileInt(L"Colors",L"Color17_R",D_Color17_R); WriteProfileInt(L"Colors",L"Color17_G",D_Color17_G); WriteProfileInt(L"Colors",L"Color17_B",D_Color17_B); WriteProfileInt(L"Colors",L"Color18_R",D_Color18_R); WriteProfileInt(L"Colors",L"Color18_G",D_Color18_G); WriteProfileInt(L"Colors",L"Color18_B",D_Color18_B); WriteProfileInt(L"Colors",L"Color19_R",D_Color19_R); WriteProfileInt(L"Colors",L"Color19_G",D_Color19_G); WriteProfileInt(L"Colors",L"Color19_B",D_Color19_B); WriteProfileInt(L"Colors",L"Color20_R",D_Color20_R); WriteProfileInt(L"Colors",L"Color20_G",D_Color20_G); WriteProfileInt(L"Colors",L"Color20_B",D_Color20_B); WriteProfileInt(L"Colors",L"Color21_R",D_Color21_R); WriteProfileInt(L"Colors",L"Color21_G",D_Color21_G); WriteProfileInt(L"Colors",L"Color21_B",D_Color21_B); WriteProfileInt(L"Colors",L"Color22_R",D_Color22_R); WriteProfileInt(L"Colors",L"Color22_G",D_Color22_G); WriteProfileInt(L"Colors",L"Color22_B",D_Color22_B); WriteProfileInt(L"Colors",L"Color23_R",D_Color23_R); WriteProfileInt(L"Colors",L"Color23_G",D_Color23_G); WriteProfileInt(L"Colors",L"Color23_B",D_Color23_B); WriteProfileInt(L"Colors",L"Color24_R",D_Color24_R); WriteProfileInt(L"Colors",L"Color24_G",D_Color24_G); WriteProfileInt(L"Colors",L"Color24_B",D_Color24_B); WriteProfileInt(L"Colors",L"Color25_R",D_Color25_R); WriteProfileInt(L"Colors",L"Color25_G",D_Color25_G); WriteProfileInt(L"Colors",L"Color25_B",D_Color25_B); WriteProfileInt(L"Colors",L"Color26_R",D_Color26_R); WriteProfileInt(L"Colors",L"Color26_G",D_Color26_G); WriteProfileInt(L"Colors",L"Color26_B",D_Color26_B); WriteProfileInt(L"Colors",L"Color27_R",D_Color27_R); WriteProfileInt(L"Colors",L"Color27_G",D_Color27_G); WriteProfileInt(L"Colors",L"Color27_B",D_Color27_B); WriteProfileInt(L"Colors",L"Color28_R",D_Color28_R); WriteProfileInt(L"Colors",L"Color28_G",D_Color28_G); WriteProfileInt(L"Colors",L"Color28_B",D_Color28_B); WriteProfileInt(L"Colors",L"Color29_R",D_Color29_R); WriteProfileInt(L"Colors",L"Color29_G",D_Color29_G); WriteProfileInt(L"Colors",L"Color29_B",D_Color29_B); WriteProfileInt(L"Colors",L"Color30_R",D_Color30_R); WriteProfileInt(L"Colors",L"Color30_G",D_Color30_G); WriteProfileInt(L"Colors",L"Color30_B",D_Color30_B); WriteProfileInt(L"Colors",L"Color31_R",D_Color31_R); WriteProfileInt(L"Colors",L"Color31_G",D_Color31_G); WriteProfileInt(L"Colors",L"Color31_B",D_Color31_B); WriteProfileInt(L"Colors",L"Color32_R",D_Color32_R); WriteProfileInt(L"Colors",L"Color32_G",D_Color32_G); WriteProfileInt(L"Colors",L"Color32_B",D_Color32_B); WriteProfileInt(L"Colors",L"Color33_R",D_Color33_R); WriteProfileInt(L"Colors",L"Color33_G",D_Color33_G); WriteProfileInt(L"Colors",L"Color33_B",D_Color33_B); StopWriteSetcion(); } ////////////////////////////////////////////////////////////////////// // LoadColors: nacitanie zakladnych nastaveni farieb ////////////////////////////////////////////////////////////////////// void CiniFile::LoadColors() { wchar_t *wTemp =new wchar_t[1024]; GetProfileInt(L"Colors",L"ColorCount",wTemp,1024); //na prazdno koly prvemu udaju Color1_R=GetProfileInt(L"Colors",L"Color1_R",wTemp,1024); Color1_G=GetProfileInt(L"Colors",L"Color1_G",wTemp,1024); Color1_B=GetProfileInt(L"Colors",L"Color1_B",wTemp,1024); Color2_R=GetProfileInt(L"Colors",L"Color2_R",wTemp,1024); Color2_G=GetProfileInt(L"Colors",L"Color2_G",wTemp,1024); Color2_B=GetProfileInt(L"Colors",L"Color2_B",wTemp,1024); Color3_R=GetProfileInt(L"Colors",L"Color3_R",wTemp,1024); Color3_G=GetProfileInt(L"Colors",L"Color3_G",wTemp,1024); Color3_B=GetProfileInt(L"Colors",L"Color3_B",wTemp,1024); Color4_R=GetProfileInt(L"Colors",L"Color4_R",wTemp,1024); Color4_G=GetProfileInt(L"Colors",L"Color4_G",wTemp,1024); Color4_B=GetProfileInt(L"Colors",L"Color4_B",wTemp,1024); Color5_R=GetProfileInt(L"Colors",L"Color5_R",wTemp,1024); Color5_G=GetProfileInt(L"Colors",L"Color5_G",wTemp,1024); Color5_B=GetProfileInt(L"Colors",L"Color5_B",wTemp,1024); Color6_R=GetProfileInt(L"Colors",L"Color6_R",wTemp,1024); Color6_G=GetProfileInt(L"Colors",L"Color6_G",wTemp,1024); Color6_B=GetProfileInt(L"Colors",L"Color6_B",wTemp,1024); Color7_R=GetProfileInt(L"Colors",L"Color7_R",wTemp,1024); Color7_G=GetProfileInt(L"Colors",L"Color7_G",wTemp,1024); Color7_B=GetProfileInt(L"Colors",L"Color7_B",wTemp,1024); Color8_R=GetProfileInt(L"Colors",L"Color8_R",wTemp,1024); Color8_G=GetProfileInt(L"Colors",L"Color8_G",wTemp,1024); Color8_B=GetProfileInt(L"Colors",L"Color8_B",wTemp,1024); Color9_R=GetProfileInt(L"Colors",L"Color9_R",wTemp,1024); Color9_G=GetProfileInt(L"Colors",L"Color9_G",wTemp,1024); Color9_B=GetProfileInt(L"Colors",L"Color9_B",wTemp,1024); Color10_R=GetProfileInt(L"Colors",L"Color10_R",wTemp,1024); Color10_G=GetProfileInt(L"Colors",L"Color10_G",wTemp,1024); Color10_B=GetProfileInt(L"Colors",L"Color10_B",wTemp,1024); Color11_R=GetProfileInt(L"Colors",L"Color11_R",wTemp,1024); Color11_G=GetProfileInt(L"Colors",L"Color11_G",wTemp,1024); Color11_B=GetProfileInt(L"Colors",L"Color11_B",wTemp,1024); Color12_R=GetProfileInt(L"Colors",L"Color12_R",wTemp,1024); Color12_G=GetProfileInt(L"Colors",L"Color12_G",wTemp,1024); Color12_B=GetProfileInt(L"Colors",L"Color12_B",wTemp,1024); Color13_R=GetProfileInt(L"Colors",L"Color13_R",wTemp,1024); Color13_G=GetProfileInt(L"Colors",L"Color13_G",wTemp,1024); Color13_B=GetProfileInt(L"Colors",L"Color13_B",wTemp,1024); Color14_R=GetProfileInt(L"Colors",L"Color14_R",wTemp,1024); Color14_G=GetProfileInt(L"Colors",L"Color14_G",wTemp,1024); Color14_B=GetProfileInt(L"Colors",L"Color14_B",wTemp,1024); Color15_R=GetProfileInt(L"Colors",L"Color15_R",wTemp,1024); Color15_G=GetProfileInt(L"Colors",L"Color15_G",wTemp,1024); Color15_B=GetProfileInt(L"Colors",L"Color15_B",wTemp,1024); Color16_R=GetProfileInt(L"Colors",L"Color16_R",wTemp,1024); Color16_G=GetProfileInt(L"Colors",L"Color16_G",wTemp,1024); Color16_B=GetProfileInt(L"Colors",L"Color16_B",wTemp,1024); Color17_R=GetProfileInt(L"Colors",L"Color17_R",wTemp,1024); Color17_G=GetProfileInt(L"Colors",L"Color17_G",wTemp,1024); Color17_B=GetProfileInt(L"Colors",L"Color17_B",wTemp,1024); Color18_R=GetProfileInt(L"Colors",L"Color18_R",wTemp,1024); Color18_G=GetProfileInt(L"Colors",L"Color18_G",wTemp,1024); Color18_B=GetProfileInt(L"Colors",L"Color18_B",wTemp,1024); Color19_R=GetProfileInt(L"Colors",L"Color19_R",wTemp,1024); Color19_G=GetProfileInt(L"Colors",L"Color19_G",wTemp,1024); Color19_B=GetProfileInt(L"Colors",L"Color19_B",wTemp,1024); Color20_R=GetProfileInt(L"Colors",L"Color20_R",wTemp,1024); Color20_G=GetProfileInt(L"Colors",L"Color20_G",wTemp,1024); Color20_B=GetProfileInt(L"Colors",L"Color20_B",wTemp,1024); Color21_R=GetProfileInt(L"Colors",L"Color21_R",wTemp,1024); Color21_G=GetProfileInt(L"Colors",L"Color21_G",wTemp,1024); Color21_B=GetProfileInt(L"Colors",L"Color21_B",wTemp,1024); Color22_R=GetProfileInt(L"Colors",L"Color22_R",wTemp,1024); Color22_G=GetProfileInt(L"Colors",L"Color22_G",wTemp,1024); Color22_B=GetProfileInt(L"Colors",L"Color22_B",wTemp,1024); Color23_R=GetProfileInt(L"Colors",L"Color23_R",wTemp,1024); Color23_G=GetProfileInt(L"Colors",L"Color23_G",wTemp,1024); Color23_B=GetProfileInt(L"Colors",L"Color23_B",wTemp,1024); Color24_R=GetProfileInt(L"Colors",L"Color24_R",wTemp,1024); Color24_G=GetProfileInt(L"Colors",L"Color24_G",wTemp,1024); Color24_B=GetProfileInt(L"Colors",L"Color24_B",wTemp,1024); Color25_R=GetProfileInt(L"Colors",L"Color25_R",wTemp,1024); Color25_G=GetProfileInt(L"Colors",L"Color25_G",wTemp,1024); Color25_B=GetProfileInt(L"Colors",L"Color25_B",wTemp,1024); Color26_R=GetProfileInt(L"Colors",L"Color26_R",wTemp,1024); Color26_G=GetProfileInt(L"Colors",L"Color26_G",wTemp,1024); Color26_B=GetProfileInt(L"Colors",L"Color26_B",wTemp,1024); Color27_R=GetProfileInt(L"Colors",L"Color27_R",wTemp,1024); Color27_G=GetProfileInt(L"Colors",L"Color27_G",wTemp,1024); Color27_B=GetProfileInt(L"Colors",L"Color27_B",wTemp,1024); Color28_R=GetProfileInt(L"Colors",L"Color28_R",wTemp,1024); Color28_G=GetProfileInt(L"Colors",L"Color28_G",wTemp,1024); Color28_B=GetProfileInt(L"Colors",L"Color28_B",wTemp,1024); Color29_R=GetProfileInt(L"Colors",L"Color29_R",wTemp,1024); Color29_G=GetProfileInt(L"Colors",L"Color29_G",wTemp,1024); Color29_B=GetProfileInt(L"Colors",L"Color29_B",wTemp,1024); Color30_R=GetProfileInt(L"Colors",L"Color30_R",wTemp,1024); Color30_G=GetProfileInt(L"Colors",L"Color30_G",wTemp,1024); Color30_B=GetProfileInt(L"Colors",L"Color30_B",wTemp,1024); Color31_R=GetProfileInt(L"Colors",L"Color31_R",wTemp,1024); Color31_G=GetProfileInt(L"Colors",L"Color31_G",wTemp,1024); Color31_B=GetProfileInt(L"Colors",L"Color31_B",wTemp,1024); Color32_R=GetProfileInt(L"Colors",L"Color32_R",wTemp,1024); Color32_G=GetProfileInt(L"Colors",L"Color32_G",wTemp,1024); Color32_B=GetProfileInt(L"Colors",L"Color32_B",wTemp,1024); Color33_R=GetProfileInt(L"Colors",L"Color33_R",wTemp,1024); Color33_G=GetProfileInt(L"Colors",L"Color33_G",wTemp,1024); Color33_B=GetProfileInt(L"Colors",L"Color33_B",wTemp,1024); delete wTemp; } ////////////////////////////////////////////////////////////////////// // SaveColorsDefault: ulozenie zakladnych nastaveni farieb ////////////////////////////////////////////////////////////////////// void CiniFile::SaveColorsDefault() { SaveColors(); } ////////////////////////////////////////////////////////////////////// // SartWriteSetcion: umozni prepis , zapis novej sekcie bez prehladavania ////////////////////////////////////////////////////////////////////// void CiniFile::SartWriteSetcion(wchar_t *pwSectionName) { int pIndex=-1; CString string(pwSectionName); GetSection(pwSectionName,&pIndex); m_bWriteSection = true; if(pIndex != -1) RemoveSection(&pIndex); string = L"[" + string + L"]"; NewSection(string); } ////////////////////////////////////////////////////////////////////// // StopWriteSetcion: umozni prepis , zapis novej sekcie bez prehladavania ////////////////////////////////////////////////////////////////////// void CiniFile::StopWriteSetcion() { m_bWriteSection = false; AddSection(sAktSection); } ////////////////////////////////////////////////////////////////////// // SartReadSetcion: umozni prepis , zapis novej sekcie bez prehladavania ////////////////////////////////////////////////////////////////////// void CiniFile::SartReadSetcion(wchar_t *pwSectionName) { int pIndex=-1; sAktSection = GetSection(pwSectionName,&pIndex); m_maxCount = 0; m_bReadSection = true; } ////////////////////////////////////////////////////////////////////// // StopReadSetcion: umozni prepis , zapis novej sekcie bez prehladavania ////////////////////////////////////////////////////////////////////// void CiniFile::StopReadSetcion() { m_bReadSection = false; m_maxCount = 0; }