Manipulating INI Files

Source: Internet
Author: User

First, INI structure of the file:
; Comments
[section name]
Keyword = value

INI file has several subsections, each with more than one keyword, and "=" followed by the value of the keyword.
There are three types of values: String, Integer value, and Boolean value.

Where strings are stored in the INI file without quotation marks,

Boolean true value is represented by 1, and Boolean false values are expressed in 0.
Comment with a semicolon ";" Beginning.

Second, the definition
1, the uses festival in interface increased inifiles;
2, add a line in the var variable definition section: myinifile:tinifile;
The variable myinifile can then be created, opened, read, written, and so on.

Third, open INI file

Filename:=extractfilepath (Paramstr (0)) + 'program. Ini '; myinifile:=tinifile. Create (filename);

Iv. reading the value of a keyword

The Tinifiles class provides three different object methods to read the values of the keywords in the INI file for the string, integer numeric, and Boolean three data types supported by the INI file.

// String Type VI: // integer Type vb:=myinifile. Readbool (' Bar name ', ' keyword ', default value); // Boolean type

V. Write INI file

// String Type  //integer class  //Boolean type

When this INI file does not exist, the above statement will also automatically create the INI file.

Vi. deletion of Keywords

Myinifile. DeleteKey (' Bar name ', ' keywords ');

Seven, subsection operation

Add a section that can be written to the method to complete, delete a section using the following object method: Myinifile. Erasesection (' subsection name '), and the Tinifile class also provides three object methods to manipulate the subsections:

Myinifile.readsection (' Bar name ', tstrings variable);

All key names in the specified section can be read into a string list variable;

Myinifile.readsections (tstrings variable);

All the subsection names in the INI file can be read into a string list variable.

Myinifile.readsectionvalues (' Bar name ', tstrings variable);

You can read all the lines (including keywords, =, values) in the specified section of the INI file into a string list variable.

Viii. Release

In the appropriate location, release myinifile with the following statement:

Myinifile.distory;

Manipulating INI Files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.