Delphi-Kylix
  Home arrow Delphi-Kylix arrow Working with INI Files in Delphi
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Working with INI Files in Delphi
By: Danish Ahmed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 15
    2007-09-04

    Table of Contents:
  • Working with INI Files in Delphi
  • TIniFile and TMemIniFile Classes
  • Working with Sections
  • TRegistryIniFile Class

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with INI Files in Delphi


    (Page 1 of 4 )

    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.

    Introduction

    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.

    [Section]
    keyname=value

    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.

    [Section]
    keyname=value1, value2, value3
    ;comment

    More Delphi-Kylix Articles
    More By Danish Ahmed


       · just a note to say thanks for your very nice article about ini files.it seems...
       · HelloI have just recently starting working with Delphi (Delphi 2010) and is...
       · Hi Crister, Unfortunately i have not been working on Delphi since a long time,so...
     

    DELPHI-KYLIX ARTICLES

    - 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...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek