Ini文件操作

//ini也可以实现多级菜单操作,需要递归搜索ini文件

TiniOptiType=(IniOpDelete,IniOpWrite,IniOpRead) //声明了一个删除、写、读的枚举类型
function iniOptiOnce(Fpath:string;IniOptiType:TiniOptiType;sec:string;key:string;value:string='';strDef:string=''):string; var configIni:TIniFile; begin Result:=''; if not FileExists(Fpath) then Exit; configIni:=TIniFile.Create(Fpath); try case IniOptiType of IniOpDelete: begin configIni.DeleteKey(sec,key); end; IniOpWrite: begin configIni.WriteString(sec,key,value); end; IniOpRead: begin Result:=configIni.ReadString(sec,key,strDef); end; end; finally configIni.Free; end; end;
原文地址:https://www.cnblogs.com/hejoy91/p/3105962.html