我先用一个动态的一维数组SectionsArray保存了index.ini中的所有sections值
var
i,j:integer;
SectionsArray:Array of string;
begin
Filename:=ExtractFilePath(Paramstr(0))+'\include\Index.ini';
  IndexIni:=TiniFile.Create(Filename);
  List:=TStringList.Create;
  IndexIni.ReadSections(List);
  j:=List.count;
  SetLength(SectionsArray,j);
  for i:=0 to j-1 do
    begin
      SectionsArray[i]:=List[i] ;
    end;
end;于是我就想用一个动态的三维数组保存section,key,value
如果有section下的key有1000多个,而有的section下的key只有3个,这样的话会不会特浪费空间请问一下有没有其他更好的办法,找了资料没有找到.

解决方案 »

  1.   

    TMemIniFile就是全部读取到内存中的不知道你这样大费周章有什么意义啊?
      

  2.   

    我忘了说
    我的index.ini中的sections,key,vlues都是未知的,
    TMemIniFile
    请问怎么个读法?
      

  3.   

    ReadSections取得所有Section
    ReadSection(sectionName,...)取得sectionName的所有key
      

  4.   


    var
      fl:TINIFile;
      str_section,str_key:TStrings;
      i,j,m,n:Integer;
      s,s1,s2:string;
    begin
      fl:=TIniFile.Create('c:\param.ini');
      str_section:=TStringList.Create;
      str_section.Clear;
      str_key:=TStringList.Create;
      str_key.Clear;
      fl.ReadSections(str_section);
      i:=str_section.Count;
      if i=0 then
        Exit;
      for j:=0 to i-1 do
      begin
        s:=str_section.Strings[j];
        fl.ReadSection(s,str_key);
        m:=str_key.Count;
        if m=0 then
          Continue;
        for n:=0 to m-1 do
        begin
          s1:=str_key.Strings[n];
          s2:=fl.ReadString(s,s1,'');
          .......................
        end;
      end;
    end;