Delphi-Kylix
  Home arrow Delphi-Kylix arrow Working with INI Files in Delphi
Iron Speed
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  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
eWeek
 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 / 6
    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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    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


     

    DELPHI-KYLIX ARTICLES

    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...
    - Using Try and Finally to Help Prevent Memory...
    - The Implementation of an FTP Server
    - FTP Server: The Theory






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway