写INI文件吧,我已经实现过了一个,我把代码发给你吧。这是我正在作的项目的一段代码。希望能对你有帮助,还有就是分数别忘记给了,我现在穷的很,:) iMonth:=GetPrivateProfileInt('报表数目','Month',0,pChar(ItemsFileName)); if iMonth=0 then MonthrpItem.Visible:=false else begin MonthrpItem.Visible:=true; MonthrpItem.Clear; for i:=1 to iMonth do begin GetPrivateProfileString('月报表',pChar('Item'+IntToStr(i)),'',@sTmp,30,pChar(ItemsFileName)); MonthItems[i]:=TMenuItem.Create(MonthrpItem); MonthItems[i].Caption:=ClearBlank1(string(sTmp)); MonthItems[i].Tag:=i; MonthItems[i].OnClick:=Fill; MonthrpItem.Add(MonthItems[i]); end; end; 其中ClearBlank是我编的一个函数,用来清除空白(sigh,也不知道怎么回事,用Trim函数清除不了)。
procedure TBaseForm.FormCreate(Sender: TObject);
var
MenuItem:TMenuItem;
begin
MenuItem:=TMenuItem.Create(Self);
MenuItem.Caption:=Caption;
MainForm.mWindow.Add(MenuItem); //mWindow是一菜單項
MenuItem.OnClick:=WinMenuClick;
end;2:隻知使用一文件或數據庫將其保存,下次登錄進加載進行創建。
我没有用过ini
而后在{$R *.dfm}前或在使用中声明var sys:Tinifile;
下面是过程中的使用
sys:=Tinifile.Create(main_win.ini_path+'\syscfg.ini');//INI文件的路径
user:=sys.ReadString('program-path','user','');读入
sysini1.WriteString('program-path','user',mc_edit.text);写入
最后要free
先要uses inifiles;
而后在{$R *.dfm}前或在使用中声明var sys:Tinifile;
下面是过程中的使用
sys:=Tinifile.Create(main_win.ini_path+'\syscfg.ini');//INI文件的路径
user:=sys.ReadString('program-path','user','');读入,user是我声明的字符串
sys.WriteString('program-path','user',mc_edit.text);写入
最后要free
iMonth:=GetPrivateProfileInt('报表数目','Month',0,pChar(ItemsFileName));
if iMonth=0 then
MonthrpItem.Visible:=false
else
begin
MonthrpItem.Visible:=true;
MonthrpItem.Clear;
for i:=1 to iMonth do
begin
GetPrivateProfileString('月报表',pChar('Item'+IntToStr(i)),'',@sTmp,30,pChar(ItemsFileName));
MonthItems[i]:=TMenuItem.Create(MonthrpItem);
MonthItems[i].Caption:=ClearBlank1(string(sTmp));
MonthItems[i].Tag:=i;
MonthItems[i].OnClick:=Fill;
MonthrpItem.Add(MonthItems[i]);
end;
end;
其中ClearBlank是我编的一个函数,用来清除空白(sigh,也不知道怎么回事,用Trim函数清除不了)。