INI配置文件的格式

C++ ini配置文件的格式及读写操作 C++ ini配置文件的格式及读写操作 1 为什么要使用ini或者其它(例如xml,json)配置文件? 如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序发布后还能根据需要进行必要的配置;配置文件有很多如INI配置文件,XML配置文件,还有就是可以使用系统注册表等。注意:ini的后缀名也不一定是".ini"也可以是".cfg",".conf ”或者是".txt"。因为ini文件实质就是txt文本文件。 2 阅读详情

为什么要用INI文件?如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序出厂后还能根据需要进行必要的配置;配置文件有很多如INI配置文件,XML配置文件,还有就是可以使用系统注册表等。

          本文主要是为读者在实现读写INI配置文件模块之前,提供有关INI文件的格式信息。

在早期的windows桌面系统中主要是用INI文件作为系统的配置文件,从win95以后开始转向使用注册表,但是还有很多系统配置是使用INI文件的。其实INI文件就是简单的text文件,只不过这种txt文件要遵循一定的INI文件格式。现在的WINCE系统上也常常用INI文件作为配置文件,这次研究INI文件的目的就是为了我的GPS定位系统客户端写个系统配置文件。“.INI ”就是英文 “initialization”的头三个字母的缩写;当然INI file的后缀名也不一定是".ini"也可以是".cfg",".conf ”或者是".txt"。

 

经典格式:

INI文件的格式很简单,最基本的三个要素是:parameters,sections和comments。

什么是parameters?

INI所包含的最基本的“元素”就是parameter;每一个parameter都有一个name和一个value,name和value是由等号“=”隔开。name在等号的左边。

如:

      name = value

什么是sections ?

所有的parameters都是以sections为单位结合在一起的。所有的section名称都是独占一行,并且sections名字都被方括号包围着([ and ])。在section声明后的所有parameters都是属于该section。对于一个section没有明显的结束标志符,一个section的开始就是上一个section的结束,或者是end of the file。Sections一般情况下不能被nested,当然特殊情况下也可以实现sections的嵌套。

section如下所示:

         [section]

 

什么是comments ?

在INI文件中注释语句是以分号“;”开始的。所有的所有的注释语句不管多长都是独占一行直到结束的。在分号和行结束符之间的所有内容都是被忽略的。

注释实例如下:

;comments text

 

当然,上面讲的都是最经典的INI文件格式,随着使用的需求INI文件的格式也出现了很多变种;

INI实例:

; last modified 1 April 2001 by John Doe  [owner]  name=John Doe  organization=Acme Products     [database]  server=192.0.2.42     ; use IP address in case network name resolution is not working  port=143  file = "acme payroll.dat"  

 

变种格式:

 请参考:http://en.wikipedia.org/wiki/INI_file



文章来源:http://blog.163.com/lyzaily@126/blog/static/42438837200911901541762/

【 C++ ini配置文件的格式及读写操作】 C++ 配置文件 阅读详情

相关推荐

delphi7 ini文件的3种类型读写

delphi7 ini文件的3种类型读写

ini配置文件的格式

为什么要用INI文件?如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序出厂后还能根据需要进行必要的配置;配置文件有很多如INI配置文件,XML配置文件,还有就是可以使用系统注册

missshirly的专栏 1123

Delphi读写UTF-8、Unicode格式文本文件 .mht

Delphi读写UTF-8、Unicode格式文本文件 .mht

.ini 配置文件中配置字典列表(List of Dicts)的最佳实践

我们常用 .ini 格式的文件来保存和使用程序配置,如何在 .ini 文件内保存字典列表(List of Dicts)形式的配置?

WEB-NOTE 4172

解密Android相机框架:从HAL到应用层的全链路解析

本文深入解析Android相机框架的全链路架构,从应用层到硬件抽象层(HAL)再到驱动层,详细介绍了CamX-CHI架构的设计哲学与实战应用。通过HAL3接口、V4L2交互机制及Camera2 API的最佳实践,帮助开发者优化相机性能,解决多摄切换、预览卡顿等常见问题,提升成像效率与稳定性。

weixin_29238147的博客 408

商品评论中的实体情感分析

在之前的文章中我已经将商品评论中的评价实体,也就是特征(feature)给挖掘出来了,我看了一下,挖掘的效果还是不错的。原文链接:http://blog.csdn.net/chixujohnny/article/details/52794685 下面一步要做的是施加情感因子,也就是说,要将人们评论时候所连带的感情程度施加一下。这项任务的归类应该是情感分析技术。 目前该类问题的情感分析技

chixujohnny 7974

DELPHI中关于读写INI文件的详细解说[转]

DELPHI中关于读写INI文件的详细解说[转] INI文件在系统配置及应用程序参数保存与设置方面,具有很重要的作用,所以可视化的编程一族,如VB、VC、VFP、Delphi等都提供了读写INI文件的方法,其中Delphi中操作INI文件,最为简洁,这是因为Delphi3提供了一个TInifile类,使我们可以非常灵活的处理INI文件

genispan的专栏 1762

BitLocker磁盘锁定解决方法

摘要:本文介绍了BitLocker加密磁盘被锁的两种情况及解决方法。对于系统盘锁定,建议在微软账户中查找48位恢复密钥;数据盘锁定可尝试密码或恢复密钥解锁。若密钥丢失,可通过IT支持或数据恢复服务尝试解决。预防措施包括妥善备份密钥到微软账户和离线位置,避免随意更改系统硬件配置。BitLocker安全性高,恢复密钥是解锁关键,提醒用户务必做好备份以防数据丢失。(148字)

yueke06442300的专栏 2681

ini配置文件格式

为什么要用INI文件?如果我们的程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序出厂后还能根据需要进行必要的配置;配置文件有很多,如INI配置文件,XML配置文件,还有就是可以使用系统注册表等。 一、简介 *.ini文件是Initialization file的缩写,即为初始化文件,是Windows系统...

小银子 8万+

C-08-实战:搭建一个AI客服机器人(接入微信企微)

客服是一人公司最大的时间杀手。本文教你搭建一个AI客服机器人,能自动回答80%的常见问题,只把复杂问题转给人工。含微信公众号和企业微信接入完整代码。

Johnny2004的专栏 89

OpenHarmony Stage模型深度解剖:从Ability Kit到沙箱隔离的全链路底层原理

基于微内核架构,提供进程管理、内存管理、IPC通信等基础能力:包含V8引擎、ArkTS运行时、渲染引擎等核心组件:Ability Kit框架,提供应用生命周期管理、组件调度等能力:基于Stage模型的应用程序。

m0_67505153的博客 193

INI配置文件格式

INI配置文件格式 文章目录INI配置文件格式0x00 INI配置文件简介0x01 文件扩展名0x02 文件格式0x03 演示实例 0x00 INI配置文件简介 配置文件:如果我们的程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,根据设计模式中的开闭原则[对扩展开放对修改关闭],我们可以使用配置文件来解决这个问题,把程序中需要改变的参数按...

Erice_s的博客 1539

无线通信中的多智能体强化学习:基于CTDE-MAPPO的功率控制优化

无线通信中的多智能体强化学习:基于CTDE-MAPPO的功率控制优化 摘要:本研究提出了一种基于集中训练分布式执行(CTDE)框架的多智能体近端策略优化(MAPPO)算法,用于解决无线通信网络的分布式功率控制问题。通过将多个基站建模为协作智能体,该系统能够在复杂动态环境中优化网络效用。算法采用集中训练获取全局信息优势,分布式执行实现高效在线决策,显著提升了网络容量和能效。实验结果表明,该方法在5G/6G网络环境中表现出优于传统方法的性能,为大规模无线网络的智能资源管理提供了有效解决方案。

huanghm88的专栏 811

C/C++ ini配置文件的格式及如何读写ini配置文件

一、ini配置文件的格式 为什么要用INI文件?如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序发布后还能根据需要进行必要的配置;配置文件有很多如INI配置文件,XML配置文件,还有就是可以使用系统注册表等。 本文主要是为读者在实现读写INI配置文件模块之前,提供有关INI文件的格式信息。在早期...

u011555996的博客 2252

YOLOv8性能突破:DySample超轻量动态上采样算子的创新应用与实现【附保姆级代码】

YOLOv8(You Only Look Once Version 8)作为YOLO系列模型的最新版本,延续了高效、准确的目标检测优势。其基础结构包含了骨干网络(Backbone)、检测头(Head)、以及特征融合层(Neck)。在特征融合阶段,YOLOv8需要对不同尺度的特征图进行上采样,以便将低分辨率的特征与高分辨率的特征进行融合。传统的上采样操作多使用插值(如双线性插值)或固定卷积,而这些方法可能无法很好地适应复杂的上下文信息。

一键难忘的博客 3124

【计算机视觉 | 目标检测】目标检测常用数据集及其介绍(十一)

【计算机视觉 | 目标检测】目标检测常用数据集及其介绍(十一)

wzk4869的博客 739

配置文件格式 INI 快速上手

INI 的全称是 Initialization,即为初始化文件,是 Windows 系统配置文件所采用的存储格式。有时候,INI 文件也会以不同的扩展名出现,如“.cfg”、“.conf”、或“.txt”。但为了可读性,不建议这么做。因为 INI 并没有一个统一的标准,所以这里介绍常用的 INI 格式内容。

Doublelv 的博客专栏。 4827

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

INI配置文件格式的说明

INI配置文件的格式 为什么要用INI文件?如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序出厂后还能根据需要进行必要的配置;配置文件有很多如INI配置文件,XML配置文件,还有就是可以使用系统注册表等。 本文主要是为读者在实现读写INI配置文件模块之前,提供有关INI文件的格式信息。 在早期的windows桌面系统中主要是用INI文件作为系统的配置文件,从win95以后开始转向使用注册表...

thanklife的专栏 2872

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

C/C++ ini配置文件的格式及读写操作

概述: 我们可能经常用到配置文件ini文件来获取或者保存参数信息,在VC中涉及的函数有如下四种 *注意:函数中的文件名必须是绝对路径,如果传入相对路径,则默认路径为C:\windows* 读取 1、读取字符串(返回值为string的长度(long型),而从ini文件获得的字符串则保留在目的缓冲器中) DWORD GetPrivateProfileString( LPCTSTR lpAppNam...

残花织梦的博客 9765

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

ini配置文件格式及用Python读写ini配置文件

1 ini配置文件介绍 1.1 概念 INI文件格式是某些平台或软件的配置文件,常用于windows操作系统 INI是英文“初始化”(initialization)的缩写。INI文件常被用来对操作系统或特定程序初始化或进行参数配置 1.2 ini文件格式 ini配置文件由三部分构成:节(section),属性(property),注释(comment)。 节(section) 节用方括号括起来,独占一行,在该section到下一个section之间的所有property(key-value)都属于

qq_41670002的博客 2214
上一篇: win8下面卸载MYSQL数据库
下一篇: 2011-10-23 10:33 VS2010中的调试技巧 断点
deathmonkey
博客等级 码龄15年 4粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值