Search results for 'INI File Close'. 1 post(s) found.

  1. 2009/08/21 How to read/wrtie INI file in Delphi ?
2009/08/21 08:47

How to read/wrtie INI file in Delphi ?


Delphi provides useful function to access INI file. With TIniFile class, you can read and write easily.

Below is the simple example writing INI files.

uses IniFiles;

...

procedure Tform1.Button1Click(Sender:TObject);
var
  myIniFile:TIniFile;
begin
  myIniFile:=TIniFile.Create(ChangeFileExt( Application.Exename,'.ini'));
  try
    myIniFile.WriteString('CompanyInfo','CompanyName','mindfire');
    myIniFile.WriteInteger('CompanyInfo',' IntVal',100);
  finally
    myIniFile.Free;
  end;
end;


And below is the example to read data from INI file.

uses IniFiles;

...

procedure Tform1.Button2Click(Sender:TObject);
var
  myIniFile:TIniFile;
  sVal:string;
  iVal:integer;

begin
  myIniFile:=TIniFile.Create(ChangeFileExt( Application.Exename,'.ini'));
  try
    sVal:= myIniFile.ReadString('CompanyInfo,'CompanyName','No Value');
    iVal:=myIniFile.ReadInteger('CompanyInfo,'IntVal',0);
    ShowMessage(sVal + IntToStr(iVal));
  finally
    myIniFile.Free;
  end;
end;


As you can see above, you can read and write data with methods. ReadString is for reading string type format from INI file, ReadInteger is for reading integer type data.
1 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Cheap phentermine.

    Tracked from Cheap phentermine online. 2010/03/03 21:12 delete

    Cheapest phentermine pills no prescription. Phentermine no prescription cheap. Phentermine cheap no prescription. Cheap phentermine no prescription. Cheap phentermine.