INI configuration file format

Why use INI files? If we do not have any program configuration files, such a program outside is completely closed, once the program need to modify some parameters need to modify and recompile the program code itself, this is very bad, so use the configuration file, also let the program after the factory you can perform the necessary configuration needed; there are many configuration files as INI configuration files, XML configuration files, there is the ability to use the system registry and so on.

          This article is for the reader to read and write before the INI configuration file module provides information on the format of the INI file.

In the early windows desktop system is mainly used as an INI file system configuration files from the win95 later turned to use the registry, but there are many system configurations using the INI file. In fact, the INI file is a simple text file, but this txt file to follow certain INI file format. Now on WINCE system is also often used as a configuration file INI files, INI files The purpose of research is to my client GPS positioning system to write the system configuration files. ".INI" is the English "initialization" the first three letters of the abbreviation; of course INI file suffix is ​​not necessarily a ".ini" may be ".cfg", "conf." Or ".txt".

INI file consists of sections, key values.  

Section
   [section]  

Parameters (key = value)
   name = value

Notes
   NOTE Using semicolon (;). In the back of the semicolon character, until the end of the line are all annotations.

NI file format is very simple, basic three elements are: parameters, sections and comments.

What are the parameters?

INI included in the basic "element" is a parameter; Each parameter has a name and a value, and the value is the name "=" separated by an equal sign. name on the left side of the equal sign.

Such as:

name = value

What are sections?

All parameters are based on sections as a unit together. All section names are on a separate line, and sections names are surrounded with square brackets ([and]). All parameters are declared in the section belonging to the section. For no apparent end of a section identifier, the beginning of a section is on the end of a section, or the end of the file. Sections can not be nested under normal circumstances, of course, special cases can be achieved in the nested sections.

section is as follows:

[section]

What are comments?

Comments in the INI file statements is a semicolon ";" began. All comments All statements no matter how long it is until the end of a line by itself. All content between a semicolon and line endings are ignored.

Notes examples are as follows:

;comments text

Of course, the above are talking about the most classic INI file format with the format requirements INI file used, there have been many variants;

INI example:

; 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"  

Guess you like

Origin www.cnblogs.com/ZackEdge/p/12043942.html