bcb 读取ini

void __fastcall TFormSet::ReadIni()
{
    listViewShow->Clear();
    String id,names,notusechar,breakchar,example;
    //----获取运行程序的目录开始
    char dir[MAX_PATH];
    char *tfile = "/Config.ini";
    //将程序现在目录所在输入此字符数组
    ::GetCurrentDirectory(MAX_PATH,dir);
    //将现在目录加上指定文件名
    strcat(dir,tfile);
    //----获取运行程序的目录结束
    //TIniFile *ini = new TIniFile(ChangeFileExt( Application->ExeName, "Config.INI" ));
    TIniFile *ini = new TIniFile(ChangeFileExt(ExtractFilePath(Application->ExeName),"Config.ini"));
    try
    {
        //listViewShow->Items->BeginUpdate();
        for(int i=1;i<=11;i++)
        {
            String strId=IntToStr(i);
            id=ini->ReadString("Lotinfo"+strId,"Id",100);
            names = ini->ReadString("Lotinfo"+strId,"Names",100);
            notusechar = ini->ReadString("Lotinfo"+strId,"Notusechar",100);
            breakchar = ini->ReadString("Lotinfo"+strId,"Breakchar",100);
            example = ini->ReadString("Lotinfo"+strId,"Example",100);
            TListItem *item;
            item=listViewShow->Items->Add();
            item->SubItems->Add(id);
            item->SubItems->Add(names);
            item->SubItems->Add(notusechar);
            item->SubItems->Add(breakchar);
            item->SubItems->Add(example);
        }
        //listViewShow->Items->EndUpdate();
    }
    catch(...)
    {
        delete ini;
        ShowMessage("xsm");
    }
    delete ini;
}

你可能感兴趣的:(ini)