看帮助了,帮助里面有例子的The following example reads information from a file into three listboxes on a form.uses IniFiles; procedure TForm1.FormActivate(Sender: TObject);var AppIni: TIniFile; begin AppIni := TIniFile.Create('win.ini'); AppIni.ReadSections(ListBox1.Items); AppIni.ReadSection('Ports',Listbox2.Items); AppIni.ReadSectionValues('Ports',ListBox3.Items); AppIni.Free; end;
procedure TForm1.FormActivate(Sender: TObject);var
AppIni: TIniFile;
begin
AppIni := TIniFile.Create('win.ini');
AppIni.ReadSections(ListBox1.Items);
AppIni.ReadSection('Ports',Listbox2.Items);
AppIni.ReadSectionValues('Ports',ListBox3.Items);
AppIni.Free;
end;
A=123
B=234
[K2]
C=xxx
D=yyyprocedure ReadSections(Strings: TStrings);
取出K1,K2添加到Strings中procedure ReadSection (const Section: String; Strings: TStrings);
取出Section项中的Key值添加到Strings中,比如Section=K2,则Strings结果是C,Dprocedure ReadSectionValues(const Section: String; Strings: TStrings);
取出Section项中的Key+Value值添加到Strings中,比如Section=K1,则Strings结果是A=123,B=234