delphi中如何动态修改程序中属性,使之在下一次运行的时候仍然保持上次修改的属性?

2025-06-23 02:54:50
推荐回答(1个)
回答1:

这里先给定蓝红黄三种颜色,根据自己需要可以在加
然后写进INI文件做为标志
use inifiles
inifile:Tinifile;

main.create();
inifile:=Tinifile.create('.\sysfile.ini');
if inifile.readstring('test','color','1')=1 then
main.color:=clblue
else if inifile.readstring('test','color','1')=2 then
main.color:=clred
else if inifile.readstring('test','color','1')=3 then
main.color:=clyellow;

//改变颜色的时候
if main.color=clblue then
inifile.writestring('test','color','1')
else if main.color=clred then
inifile.writestring('test','color','2')
else if main.color=clyellow then
inifile.writestring('test','color','3');

inifile.free;