INI文件做成下面形式应该好处理了吧[Main]
MainCount=2[Main1]
NumCount=3
Num1=
Num2=
Num3=[Main2]
NumCount=4
Num1=
Num2=
Num3=
Num4=

解决方案 »

  1.   

    用TStringList:
    var
      Hostini:Tinifile;
      HostName:TstringList;
      filename:string;
      i:integer;
    begin
      filename:=extractfilepath(paramstr(0))+'Host.ini';
      hostini:=tinifile.Create(filename);
      hostname:=tstringlist.Create;
      hostname.Add('asdf');
      try
        hostini.ReadSection('HOST',hostname);//在这里出现抽象错误,不知为什么
        combobox2.Items.Clear;
        for i:=0 to hostname.Count-1 do
        begin
          combobox2.Items.Add(hostini.ReadString('HOST',hostname[i],'HPFS2'));
        end;{for}
       combobox2.ItemIndex:=0;
      finally
        hostini.Destroy;
        hostname.Destroy;
      end;