怎样用tinifile修改section的内容在写回到ini文件中!!! (50分)

B

bmwbey

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样用tinifile修改section的内容在写回到ini文件中!!!
在线等待!!!!!!!!!!!!!!!!!!!!
 
似乎不行,不如当作普通文本文件处理,或用TStringList,很方便的。
 
那我再问一下怎样一下子删除一个section以及他的所有值!!!
 
myinfile.erasesection('小姐名');//删除该小姐
 
看delphi的帮助啊,很详细的啊
 
其实修改section的内容用TStringList是很简单的。

procedure TForm1.Button1Click(Sender: TObject);
var
ini: TStringList;
begin
ini := TStringList.Create;
ini.LoadFromFile('LanExplorer.ini');
ini.Strings[ini.IndexOf('[window position]')] := '[position]'; //修改section的内容
ini.SaveToFile('LanExplorer.ini');
ini.Free;
end;
 
TIniFile都有这些功能呀!!
删除一个Section:
TIniFile.EraseSection
procedure EraseSection(const Section: String); override;
删除一个键值:
TIniFile.DeleteKey
procedure DeleteKey(const Section, Ident: String); override;
将修改后的数据立即更新到文件
function UpdateFile; override;

直接释放对象,也会自动保存到文件
ok,够详细了吧?
 
多人接受答案了。
 
顶部