1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| 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;
procedure TForm1.Button2Click(Sender: TObject);
var
MyIniFile: TIniFile;
begin
MyIniFile := TIniFile.Create('myapp.ini');
{ if the entry wasnt there before, delete it now }
if Memo1.Lines.Values['Title1'] = '' then
MyIniFile.DeleteKey('Transfer', 'Title1')
{ otherwise, restore the old value }
else
MyIniFile.WriteString('Transfer', 'Title1', Memo1.Lines.Values['Title1']);
MyIniFile.Free;
end; |
Partager