InnoSetup中枚举出INI文件的所有sections和键值
原文 http://blog.chinaunix.net/uid-23480430-id-3016899.html
InnoSetup支持一些INI文件操作函数,
- procedure ArrayAddStr(var Arr: Array of String; Str: String);
- var
- Len: Longint;
- begin
- Len := GetArrayLength(Arr);
- SetArrayLength(Arr, Len + 1);
- Arr[Len] := Str;
- end;
- //-- INI
- function IniGetSectionName(Line: String; var Name: String): Boolean;
- var
- P0, P1: Integer;
- begin
- Line := TrimLeft(Line);
- P0 := Pos('[', Line);
- P1 := Pos(']', Line);
- if (P0 = 1) and (P1 > P0 + 1) then begin
- Name := Copy(Line, P0 + 1, P1 - P0 - 1);
- Result := True;
- end
- else
- Result := False;
- end;
- function IniGetKeyName(Line: String; var Name: String): Boolean;
- var
- P0, P1: Integer;
- begin
- Line := TrimLeft(Line);
- P0 := Pos('=', Line);
- P1 := pOS(';', Line); //; is start of comment
- if (P0 > 1) and ((P1 = 0) or (P1 > P0)) then begin
- Name := Trim(Copy(Line, 1, P0 - 1));
- Result := True;
- end
- else
- Result := False;
- end;
- procedure IniGetSections(var Arr: Array of String; const Path: String);
- var
- i: Longint;
- Name: String;
- Lines: Array of String;
- begin
- SetArrayLength(Arr, 0);
- if not LoadStringsFromFile(Path, Lines) then exit;
- for i := 0 to GetArrayLength(Lines) - 1 do begin
- if IniGetSectionName(Lines[i], Name) then ArrayAddStr(Arr, Name);
- end;
- end;
- procedure IniGetKeys(var Arr: Array of String; const Path: String; const Section: String);
- var
- i: Longint;
- Name: String;
- Lines: Array of String;
- begin
- SetArrayLength(Arr, 0);
- if not LoadStringsFromFile(Path, Lines) then exit;
- for i := 0 to GetArrayLength(Lines) - 1 do begin
- if IniGetSectionName(Lines[i], Name) then begin
- if CompareText(Name, Section) = 0 then break;
- end;
- end;
- if i < GetArrayLength(Lines) then begin
- { The section is }
- for i := i + 1 to GetArrayLength(Lines) - 1 do begin
- if IniGetSectionName(Lines[i], Name) then break
- else if IniGetKeyName(Lines[i], Name) then ArrayAddStr(Arr, Name);
- end;
- end;
- end;
InnoSetup中枚举出INI文件的所有sections和键值的更多相关文章
- 向php文件中添加php.ini文件
向php文件中添加php.ini文件 默认情况下,php是没有php.ini配置文件的,必须手工添加php.ini文件 在php安装目录中,复制php.ini文件到/usr/local/php/lib ...
- [转载]windows7中没用boot.ini文件而是改用BCDEDIT来配置了
原文地址:windows7中没用boot.ini文件而是改用BCDEDIT来配置了作者:开心骝哥 本人安装的Win7,因为机上有两个系统,一个dos系统,一个win7系统,开机时总是会在系统选择的界面 ...
- win7下iis中配置php.ini文件
将php.ini-development配置文件重命名为php.ini配置文件即可. 接着做如下配置操作: 1.修改php.ini配置文件 打开php.ini配置文件,找到 12 ; On windo ...
- web安全之php中常见的INI文件配置
php.ini 在 PHP 启动时被读取.对于服务器模块版本的 PHP,仅在 web 服务器启动时读取 一次.对于 CGI 和 CLI 版本,每次调用都会读取. * Apache web 服务器在启动 ...
- IDEA中怎么创建ini文件
首先博主在这使用的是idea的2019.3.2的版本,不知道的话可以打开help菜单的about查看 第一步: 具体需要在setings安装ini插件 第二步: 在File Types中查看ini,没 ...
- 获取ini文件所有的Sections和Keys
获取ini文件中所有的Sections和Keys,并以pair对的方式存入到vector中 #include <iostream> #include <windows.h> # ...
- 利用FastJson,拼接复杂嵌套json数据&&直接从json字符串中(不依赖实体类)解析出键值对
1.拼接复杂嵌套json FastJson工具包中有两主要的类: JSONObject和JSONArray ,前者表示json对象,后者表示json数组.他们两者都能添加Object类型的对象,但是J ...
- Nginx中修改php.ini的上传设置upload_max_filesize的值
普遍的网络越来越快,以前小家子气的2M上传限制慢慢变得不合时宜了.最近就把2M的限制直接提升到了20M...代码层面很快就修改好了,没什么可说的.但是上线的话还得修改一下服务器的配置.服务器是Ngin ...
- 关于C#操作INI文件的总结
原文:关于C#操作INI文件的总结 INI文件其实是一种具有特定结构的文本文件,它的构成分为三部分,结构如下: [Section1]key 1 = value2key 1 = value2--[S ...
随机推荐
- python编程之字符串转处理
比如255的16进制是FF. 转换成整型就是 int("FF",16) console上输出就是255 int("FFFF",16)就是65535 如 ...
- Teach Yourself Scheme in Fixnum Days 6 recursion递归
A procedure body can contain calls to other procedures, not least itself: (define factorial (lambda ...
- 开始使用Logstash
开始使用Logstash 本节将指导处理安装Logstash 和确认一切是运行正常的, 后来的章节处理增加负载的配置来处理选择的使用案例. 这个章节包含下面的主题: Installing Logsta ...
- Linux企业级项目实践之网络爬虫(18)——队列处理
所有的URL都接受管理,并在此进行流动.URL从管理模块的存储空间开始,一直到最后输出给磁盘上的URL索引,都由此部分调度.首先,给出URL调度的一般过程,如图所示.其流程的各个具体操作,后面详述.要 ...
- hibernate错题解析
01 Hibernate错题分析 解析: 此题目考查的是对Hibernate中交叉连接的理解.HQL支持SQL风格的交叉连接查询,交叉连接适用于两个类之间没有定义任何关联时.在where字句中,通 ...
- git 技巧
将某个文件回退到某个版本 git co d359624286d9c1f022b8b3b6f2d3fe3b6524188b build.sh 查看某个文件在某个版本时的内容 git show d3596 ...
- AngularJs学习笔记4——四大特性之双向数据绑定
双向数据绑定 方向1:模型数据(model)绑定到视图(view) 实现方法:①.{{model变量名}} ②.常用指令(ng-repeat) 方向2:将视图(view)中用户输入的数据绑定到模型数 ...
- Hadoop,HBase集群环境搭建的问题集锦(四)
21.Schema.xml和solrconfig.xml配置文件里參数说明: 參考资料:http://www.hipony.com/post-610.html 22.执行时报错: 23., /comm ...
- android调试系列--使用ida pro调试so
1.工具介绍 IDA pro: 反汇编神器,可静态分析和动态调试. 模拟机或者真机:运行要调试的程序. 样本:阿里安全挑战赛第二题:http://pan.baidu.com/s/1eS9EXIM 2. ...
- NFinal 控制器—URL
URL路由规则 规则:http://网址/模块名/控制器的相对路径的文件名/函数名.htm 例: http://localhost/App/IndexController/Index.htmhttp: ...