Home arrow Delphi-Kylix arrow Working with INI Files in Delphi

Working with INI Files in Delphi

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.

Author Info:
By: Danish Ahmed
Rating: 5 stars5 stars5 stars5 stars5 stars / 25
September 04, 2007
  1. · Working with INI Files in Delphi
  2. · TIniFile and TMemIniFile Classes
  3. · Working with Sections
  4. · TRegistryIniFile Class

print this article

Working with INI Files in Delphi
(Page 1 of 4 )


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.

keyname=value1, value2, value3

blog comments powered by Disqus

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials