码迷,mamicode.com
首页 > 其他好文 > 详细

Delphi ini文件读写

时间:2014-09-13 10:31:54      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   使用   ar   for   文件   div   

首先把IniFiles加入到interface的uses里,这样才能使用Tinifile类,其他代码如下

implementation

{$R *.dfm}

var
    inifile: Tinifile;
    filepath: string;

procedure TForm1.Button1Click(Sender: TObject);
begin
    inifile.WriteString(‘Common‘, ‘PortNumber‘, Edit1.Text);
    inifile.WriteString(‘Common‘, ‘Brand‘, Edit2.Text);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    filepath := ExtractFilePath(Application.Exename) + ‘reg.ini‘;//取得ini文件的路径
    inifile := Tinifile.Create(filepath);
    Edit1.Text := inifile.ReadString(‘Common‘, ‘PortNumber‘, ‘‘);
    Edit2.Text := inifile.ReadString(‘Common‘, ‘Brand‘, ‘‘);
end;

 

Delphi ini文件读写

标签:style   blog   color   io   使用   ar   for   文件   div   

原文地址:http://www.cnblogs.com/lilongjiang/p/3969489.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!