DELPHI中对INI文件的读写

来源:互联网 发布:什么是网络互联 编辑:程序博客网 时间:2024/05/22 16:47

function readInifile(fileName,section,Ident:string):string;  //读取配置文件
var
  ini:tinifile;
begin
  ini:=tinifile.Create(fileName);
  result:=ini.ReadString(section,ident,'');
  ini.Free;
end;

procedure writeInifile(const fileName,Section, Ident, Value: string); //写inifile
var
  ini:tinifile; aPathName:string;
begin
  try
    aPathName:= ExtractFileDir(fileName);
    if not DirectoryExists(aPathName) then
      ForceDirectories(aPathName);

    ini:=tinifile.Create(fileName);
    ini.WriteString(Section, Ident, Value);
    ini.Free;
  except
  end;
end;

原创粉丝点击