获取ini文件所有的Sections和Keys
获取ini文件中所有的Sections和Keys,并以pair对的方式存入到vector中
#include <iostream>
#include <windows.h>
#include <string>
#include <vector>
using namespace std; #define PATH "E:\\vc_code\\parse_ini\\cfg.ini"
int main()
{
char buff[] = {};
vector<string> vecSections;
vector<string> vecKeys;
vector<pair<string, string>> vecSectionKey;
int num = GetPrivateProfileSectionNames(buff, , PATH);
size_t startpos = ;
for (size_t i = ; i < num; ++i)
{
if ('\0' == buff[i])
{
string tmp(buff + startpos, buff + i);
startpos = i + ;
vecSections.push_back(tmp);
}
} for (size_t i = ; i < vecSections.size(); ++i)
{
char buffkey[] = {};
num = GetPrivateProfileSection(vecSections[i].c_str(), buffkey, , PATH);
startpos = ;
for (size_t j = ; j < num; ++j)
{
if ('\0' == buffkey[j])
{
string tmp(buffkey + startpos, buffkey + j);
startpos = j + ;
size_t pos = tmp.find('=');
vecKeys.push_back(tmp.substr(, pos)); vecSectionKey.push_back(make_pair(vecSections[i], tmp.substr(, pos)));
}
}
} return ;
}
获取ini文件所有的Sections和Keys的更多相关文章
- InnoSetup中枚举出INI文件的所有sections和键值
原文 http://blog.chinaunix.net/uid-23480430-id-3016899.html InnoSetup支持一些INI文件操作函数, 例如GetIniString,Ini ...
- C#如何读写和创建INI文件
在做项目过程中,有时需要保存一些简单的配置信息,可以使用xml,也可以使用INI文件.下面是C#中读取INI的方法,相信大部分朋友都使用过这种方式.INI文件的存储方式如下, [section] ke ...
- C#如何读写和创建INI文件(经典)转
C#如何读写和创建INI文件 分类: c#程序设计2011-11-27 20:42 4935人阅读 评论(2) 收藏 举报 inic#stringbuffernullfile 在做项目过程中,有时需要 ...
- C# 创建INI文件,写入并可读取。----转载
基于C#winform设计. 首先创建一个类,我命名为IniFiles.并引入命名空间using System.Runtime.InteropServices; 接着,声明API函数 [DllImpo ...
- python操作ini文件
简介 ini文件作为常见的配置文件,因此需要对ini文件做处理,此处使用configparser模块,本文介绍以下ini文件常用的处理方式. 需要读取的ini文件 如下文件,[ ]包含的称为secti ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- C#读写ini文件操作
ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...
- C# 操作.ini文件
1.声明变量 #region "声明变量" /// <summary> /// 写入INI文件 /// </summary> /// <param n ...
- winfrom 操作 INI 文件 分类: WinForm 2014-07-22 12:49 156人阅读 评论(0) 收藏
<strong><span style="font-size:18px;">(1)INI文件的名称:FileConfig.ini</span>& ...
随机推荐
- 一致性hash
1,一致性hash函数选择 crc32(范围为0到2的32次方),超过最大值,需要求模 :md5,求得16进制数据,超过最大值,需要求模 : 2,对cache server的虚拟节点的某些唯一属性或者 ...
- JavaScript 回车 焦点切换(摘抄)
<!-- 这是回车转换行的代码段--> <script language='javascript' for='document' event='onkeydown'> if(e ...
- URL传参中文乱码encodeURI、UrlDecode
传递参数 encodeURI("url.aspx?str"+"汉字")-----------(是 URi 不是URL) 后台接收参数 Server.Url ...
- js 去重 字符串 [123123,123123,345435,33467,45645,343467,879,45645]
function unique(dislodgeArr) { var ret = [] var hash = {} var datasource = new Array(); var array= d ...
- JS中的Function对象
Function是函数的原型,所有的函数都来源于Function,获得函数的方法有两种类型,分为动态函数和函数继承. 动态函数 创建一个Function语法: var func = new Funct ...
- ChildNodes详解及其兼容性处理方式
写在前面:在做insertBefore插入节点练习时发现一个问题,插入childNodes[0]和childNodes[1]时插入的位置是一样的!于是有了childNodes的了解,有了这篇文章,欢迎 ...
- oracle操作语句
Oracle中建立索引,会提高查询速度: create index 索引名 on 表名(列名); create index index_userid on tbl_detail(userid);如何找 ...
- zookeeper_00:zookeeper注意事项
需要将应用数据和协同数据独立开. 比如:网络邮箱服务的用户对自己邮箱中的内容感兴趣,但是并不关心由哪台服务器来处理特定邮箱的请求.在这个例子中,邮箱内容就是应用数据,而从邮箱到某一台邮箱服务器之间的映 ...
- 库函数strlen源码重现及注意问题
首先直接上源码: size_t strlen (const char * str) { const char *eos = str; while(*eos++); return(eos - str - ...
- The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. 异常
异常信息如下: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without t ...