Search results for 'INI File Close'. 1 post(s) found.
- 2009/08/21 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;
...
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;
...
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.
Another posts included in "Delphi"
| Delphi Pointer Types (0) | 2009/08/22 |
| Get the length of arrays and a string (0) | 2009/08/22 |
| How to resize PNG file in Delphi ? (0) | 2009/09/03 |
| How to get file created time, modified time, and last accessed time ? (0) | 2009/08/19 |
| Delphi string conversion functions - AnsiToUTF-8, UTF8Encode, ... (0) | 2009/07/20 |
| When subject is crashing in TIdSMTP VCL (0) | 2009/07/20 |
| How to send text/html based email in UTF-8 with TIdSMTP, TIdMessage VCL (0) | 2009/07/20 |
| How to encode subject content when sending mail with TIdMessage ? (0) | 2009/07/16 |
Trackback : Cannot send a trackbact to this post.
-
Subject Cheap phentermine.
2010/03/03 21:12
Cheapest phentermine pills no prescription. Phentermine no prescription cheap. Phentermine cheap no prescription. Cheap phentermine no prescription. Cheap phentermine.

Prev

Rss Feed