Microsoft has taken steps to phase out .ini or initialization files, but they are too useful in too many situations to completely disappear just yet. For example, there are specific cases where you would want to use an INI file when developing a cross-platform application. This article explains how to create and use an INI file in Delphi.
If you are a Windows user, you are sure to have come across files with .ini extensions. .INI files or initialization files are configuration files containing application information in plain text which can be viewed and modified by the user as well as applications. Since the release of Windows 95 Microsoft has recommended use of the Windows Registry for storing application information, but .INI files have not entirely been put out of use, probably because they are easier and safer to handle than the Registry.
INI files can also be useful when developing cross-platform applications where one of the targeted platforms doesn't have a registry. Lately, XML files are also used to store configuration data, but the fact remains that .INI files are still popular among certain sections of programmers. In fact Microsoft Windows itself uses .INI files, like System.ini and Win.ini, to store important configuration data that it requires. Delphi too uses the INI file format in the form of .dsk files to store desktop setting. In this article I will show how to create and use an INI file in Delphi.
As I said earlier, an INI file is basically a text file that stores application data for later use. The information is stored in "sections" which have pairs of keys and values. While the keys identify the information stored, values are the actual information that can be used by the application. This is similar to the Windows registry but there is a glaring dissimilarity in the form of a size restriction on the INI file.
The Windows API requires that an INI file be less than 64 KB and each section should not exceed 8 KB of memory. However, a section may contain zero keys or more and each key can hold zero or more values. A section is enclosed within square brackets  and should be placed at the beginning of the line. The key name is specified in the next line and is separated from the value by an equal ("=") sign. If the section appears more than once in the same file or the key name is repeated in the same section, the last section or key that occurred will be read.
You can add comments by adding a semi-colon (;) in the beginning of the line. Characters occurring after the semi-colon and before the termination of the line are ignored by the parser. Multiple values for a key can be provided by separating them with comma and a space character.