用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;
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;