ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • TIniFile ::ReadSectionValues
    C++ Builder/함수 2019. 1. 25. 15:12

    TIniFile * test = new TIniFile("C:\\My\\test.ini"); //ini파일 

    TStringList * SecList = new TStringList; //색션 리스트 
    TStringList * ValueList = new TStringList; //값 리스트 

    test->ReadSections(SecList); //test색션리스트 읽어오기 

    for(i = 0;i < SecList->Count; i++){ 
      test->ReadSectionValues(SecList->Strings[i], ValueList); 



    ex)  섹션에서 키값만 따로 리스트로 읽어오기


    void __fastcall TMainF::fnLoadData()

    {

    TStringList *pList     = new TStringList();

    TStringList *pTempList = new TStringList();

    TStringList *pSectList = new TStringList();


    UnicodeString sTemp = "";

    UnicodeString sShow = "";

    AnsiString sPath;

    sPath  = ExtractFilePath(Application->ExeName) + "TcpServer_Project.ini";


    TIniFile* pIni  = new TIniFile(sPath);


    pTempList->Delimiter = '=';

    pIni->ReadSections(pSectList); // 각 섹션을 리스트로 읽어오기

    // 섹션 키이름과 키값을 리스트로 읽어오기

    for (int i = 0; i < pSectList->Count ; i++) {

    pIni->ReadSectionValues(pSectList->Strings[0], pList);

    }

    // 키이름과 키값 확인출력

    for (int i=0; i<pList->Count; i++) {

    Memo1->Lines->Add(pList->Strings[i]);

    }


    // 키값만 따로 리스트로 읽어오기

    for (int i=0; i<pList->Count; i++) {

    sTemp = pList->Strings[i];

    pTempList->DelimitedText = sTemp;

    sShow += (pTempList->Strings[1] + ",");

    }

    pList->Clear();

    pList->CommaText = sShow;


    // 키값 확인출력

    for (int i=0; i<pList->Count; i++) {

    Memo1->Lines->Add(pList->Strings[i]);

    }


    delete pSectList;

    delete pTempList;

    delete pList;

    delete pIni;

    }

    728x90

    'C++ Builder > 함수' 카테고리의 다른 글

    isdigit  (0) 2019.03.25
    MessageBox  (0) 2019.03.06
    ForceDirectories  (0) 2019.01.25
    ExtractFilePath()  (0) 2019.01.24
    #OutputDebugString  (0) 2019.01.24

    댓글

Designed by Tistory.