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 ...
随机推荐
- sql中update,alter,modify,delete,drop的区别和使用(整理)(转)
关于update和alter: 百度知道上关于update和alter有一个很形象的总结: 一个表有很多字段,一个字段里有很多数据. 一个家有很多房间,一个房间里有很多家具. update是用来将衣柜 ...
- OR扩展
<pre name="code" class="sql">SQL> select substr(xx.acct_no,1,5) agent_o ...
- 转:String.Empty、string=”” 和null的区别
原文地址:http://www.cnblogs.com/fanyong/archive/2012/11/01/2750163.html String.Empty是string类的一个静态常量: Str ...
- 在线服装零售商Betabrand获得650万美元风投 - 投资风向 - 创业邦
在线服装零售商Betabrand获得650万美元风投 - 投资风向 - 创业邦 在线服装零售商Betabrand获得650万美元风投
- PDO如何选择其他数据库的驱动
$dsn = "mysql(用的mysql的驱动):dbname=testdb(连接数据库名称);host=127.0.0.1(IP地址,本地是:localhost)"
- 7 个改变世界的 Java 项目
英文链接:http://radar.oreilly.com/2011/07/7-java-projects.html 文章转载自:开源中国社区 http://www.oschina.net/news/ ...
- CGI、FastCGI和php-fpm的区别
参考网上的描述,将网上的描述内容,整理进来: 首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的,方便CGI程序的编写者.web server(比如说nginx)只是 ...
- ASP.NET 实现PDF文件下载
本文介绍了一种在ASP.NET中下载文件的方法. 方法一:可能是最简单的.最短的方式: Response.ContentType = "application/pdf"; Resp ...
- [置顶] STM32移植contiki进阶之三(中):timer 中文版
鉴于自己英语水平不高,在这里,将上一篇关于contiki 的timer的文章翻译为中文,让自己在学习的时候,更方便点.文中有许多不是很通顺的地方,将就吧. Timers Contiki系统提供了一套时 ...
- 仿糯米弹框效果demo
代码例如以下: <!doctype html> <html lang="en"> <head> <meta charset="U ...