procedure TForm1.FormActivate(Sender: TObject);var MyIniFile: TIniFile; begin MyIniFile := TIniFile.Create('myapp.ini'); with MyIniFile do begin if ReadBool('AutoLoad', 'FormProperties', False) = True then begin Visible := ReadBool('FormOptions', 'Visible', True); Color := TColor(ReadInteger('FormOptions', 'Color', clNormalBackground)); Caption := ReadString('FormOptions', 'Caption', 'Main'); end; MyIniFile.Free;end;
procedure TForm1.Button1Click(Sender: TObject);var MyIniFile: TIniFile; begin MyIniFile := TIniFile.Create('myapp.ini'); Memo1.Clear; MyIniFile.ReadSectionValues('Transfer', Memo1.Lines); if Memo1.Lines.Values['Title1'] <> 'Picture Painter' then MyIniFile.WriteString('Transfer', 'Title1', 'Picture Painter'); MyIniFile.Free; end;
MyIniFile: TIniFile;
begin
MyIniFile := TIniFile.Create('myapp.ini');
with MyIniFile do
begin
if ReadBool('AutoLoad', 'FormProperties', False) = True then
begin
Visible := ReadBool('FormOptions', 'Visible', True);
Color := TColor(ReadInteger('FormOptions', 'Color', clNormalBackground));
Caption := ReadString('FormOptions', 'Caption', 'Main');
end;
MyIniFile.Free;end;
MyIniFile: TIniFile;
begin
MyIniFile := TIniFile.Create('myapp.ini');
Memo1.Clear;
MyIniFile.ReadSectionValues('Transfer', Memo1.Lines);
if Memo1.Lines.Values['Title1'] <> 'Picture Painter' then
MyIniFile.WriteString('Transfer', 'Title1', 'Picture Painter');
MyIniFile.Free;
end;
我是想 读取 my.ini 里面的所有的节点添加到 listbox1 的列表里面。
Ident 是变量
v 是值
iniFile := TiniFile.Create(extractfilepath(application.ExeName) + 'abc.ini');
try
v := inifile.ReadString('system', Ident, v);
finally
inifile.Free;
end;