首先
uses
inifiles
然后写文件
-
procedure THolidaySet.Button2Click(Sender: TObject);
-
var
-
IniFile:TIniFile;
-
Count:Integer;
-
begin
-
-
try
-
IniFile:=TIniFile.Create(TPath.GetHomePath+'\HolidayRobot.ini');
-
Count:=IniFile.ReadInteger('Config','Count',0);
-
Count:=Count+1;
-
-
IniFile.WriteString('Holiday'+IntToStr(Count),'TEL',Edit1.Text);
-
IniFile.WriteString('Holiday'+IntToStr(Count),'NAME',Edit2.Text);
-
IniFile.WriteString('Holiday'+IntToStr(Count),'DATETIME',CalendarEdit1.Text);
-
IniFile.WriteString('Holiday'+IntToStr(Count),'CONTENT',Edit4.Text);
-
-
IniFile.WriteInteger('Config','Count',Count);
-
finally
-
FreeAndNil(IniFile);
-
end;
-
end;
复制代码
读INI文件
-
procedure TForm1.FormShow(Sender: TObject);
-
var
-
IniFile:TIniFile;
-
Count:Integer;
-
I:Integer;
-
begin
-
try
-
IniFile:=TIniFile.Create(TPath.GetHomePath+'\HolidayRobot.ini');
-
Count:=IniFile.ReadInteger('Config','Count',0);
-
-
for I := 1 to Count do
-
begin
-
Memo1.Lines.Add(inifile.ReadString('Holiday'+IntToStr(I),'TEL',''));
-
end;
-
finally
-
FreeAndNil(IniFile);
-
end;
-
end;
-
复制代码
本文转自鹅倌51CTO博客,原文链接: http://blog.51cto.com/kaixinbuliao/1575948,如需转载请自行联系原作者