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 ...
随机推荐
- FTP 上传文件
有时候需要通过FTP同步数据文件,除了比较稳定的IDE之外,我们程序员还可以根据实际的业务需求来开发具体的工具,具体的开发过程就不细说了,这里了解一下通过C#实现FTP上传文件到指定的地址. /// ...
- PHP中文汉字验证码
hb.ttf换成随便你自己下载的ttf Header("Content-type: image/PNG"); $str="的一是在了不和有大这主中人上为们地个用工时要动国 ...
- Spring事务管理器分类
Spring并不直接管理事务,事实上,它是提供事务的多方选择.你能委托事务的职责给一个特定的平台实现,比如用JTA或者是别的持久机制.Spring的事务管理器可以用下表表示: 事务管理器的实例 目标 ...
- 编写jeb插件打印目标方法的交叉引用
jeb插件的编写,文档在文件夹\jeb_1.5\doc\apidoc. 我这里的目的是回溯sendTextMessage等敏感api的调用路径,实现代码如下: from jeb.api import ...
- 【Nginx】事件和连接
不同的操作系统相应不同的事件驱动机制.在Linux 2.6之后使用epoll机制.相应的事件驱动模块是ngx_epoll_module.Nginx的ngx_event_core_module模块依据操 ...
- ibatis之##与$$的 使用
/** 主要讲一下ibatis中$$的使用: 是为了传递参数; 参数一定在Action层用''包裹起来: */ List <SysRole> userList= systemService ...
- iOS程序的加载过程
1.执行main函数2.执行UIApplicationMain函数1> 创建一个UIApplication对象(UIApplication是整个程序的象征)一个应用只有一个application ...
- visual studio 一直显示正在准备解决方案
首先重启电脑,无法解决的情况下执行以下步骤: Kill Visual Studio Open Visual Studio without loading a solution Disable Ankh ...
- View not attached to window manager
java.lang.IllegalArgumentException: View not attached to window manager 在用ProgressDialog的时候,任务结束后Dis ...
- ios--图片处理(修改、保存)UIGraphicsBeginImageContext
http://www.th7.cn/Program/IOS/201407/250904.shtml