ini文件是windows的系统配置文件, 被用来对操作系统或特定程序初始化或进行参数设置. 在Windows系统中,INI文件是很多,最重要的就是“System.ini”、“System32.ini”和“Win.ini”。该文件主要存放用户所做的选择以及系统的各种参数。用户可以通过修改INI文件,来改变应用程序和系统的很多配置。
中间的数据格式一般为:
;注释(Comments)
[Section1 Name]
KeyName1=value1
KeyName2=value2
...
[Section2 Name]
KeyName1=value1
KeyName2=value2
ini 文件可以分为几个 Section,每个 Section 的名称用 [] 括起来,在一个 Section 中,可以有很多的 Key,每一个 Key 可以有一个值并占用一行,格式是 Key=value,注释以分号";"开头。
Windows提供了几个有用的API来读写操作INI文件:
GetPrivateProfileSection - 从 ini 文件中读出整个 Section 的内容
WritePrivateProfileSection - 将一个整个 Section 的内容入 ini 文件的指定 Section 中
WritePrivateProfileString - 将一个 Key 值写入 ini 文件的指定 Section 中