zoukankan      html  css  js  c++  java
  • ini文件读写

    //创建对象:
    iniFile:=TIniFile.Create(strFile);

    //写入
    procedure IEAddFavUrl(FURL, Title: string);
    var
      fPath: string;
    begin
      fPath := GetFavoritesPath;
      with TIniFile.Create(fPath + Title + '.url') do
      try
        WriteString('InternetShortcut', 'URL', FURL);
      finally
        free;
      end;
    end;

    //读取单个子节点的值
    function AWS_GET_HomeWebAddr:String;
    var
      strPath,strDefault,strWebAddr:string;
      AWSIni:TIniFile;
      Buffer:array[0..MAX_PATH] of Char;
    begin
      strDefault:='http://'+GStack.LocalAddress;
     
      ZeroMemory(@Buffer[0],SizeOf(Buffer));
      GetWindowsDirectory(@Buffer[0],MAX_PATH);
      strPath:=StrPas(@Buffer[0])+'Aws.ini';
      AWSIni:=TIniFile.Create(strPath);
      strWebAddr:=AWSIni.ReadString('config','Aws_LocalIp','');
      AWSIni.Free;

      if strWebAddr='' then
        strWebAddr:=strDefault;
      Result:=strWebAddr;
    end;


    //读取整个节点下的值和字节点名称
      strFile:=StrBackupPath+'data.ini';
      iniFile:=TIniFile.Create(strFile);
      sl:=TStringList.Create;
      slValue:=TStringList.Create;
      iniFile.ReadSections(sl);//读取ini文件中所有的一级节点到sl中。
      iniFile.ReadSection('comm',sl);//读取comm节点下所有子节点名称到sl中.
      iniFile.ReadSectionValues('comm',slValue);//读取comm节点下所有子节点的名称和值到slValue中:id=123

  • 相关阅读:
    购买 Linux VPS 服务器后简单的安全设置
    VPS性能测试:CPU内存,硬盘IO读写,带宽速度,UnixBench和压力测试
    Polysh实现多服务器批量执行shell
    第十一周编程总结
    第十周作业
    第九周编程总结修改
    第九周编程总结
    第八周编程总结
    第7周编程总结
    第七周编程总结啊
  • 原文地址:https://www.cnblogs.com/weijie-liu/p/9644847.html
Copyright © 2011-2022 走看看