IniFile:TIniFile
IniFile:=TIniFile.Create
IniFile.DeleteKey();

解决方案 »

  1.   

    好像不能删除节点,只是清空而已,哈哈不知道对不对
    好久好久没有用ini了
      

  2.   

    This example reads the Transfer section of the myapp.ini file into a memo and changes one of the strings in the INI file when Button1 is clicked.  When Button2 is clicked, the myapp.ini file is restored to its initial state, using the values stored in the memo.
    Before you run this example, you must add the IniFiles unit to the uses clause of your unit.Warning: Do not click button2 before you have clicked button1!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 wasn抰 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;