参考一下。
uses Inifiles;
procedure TMainForm.OpenIni;
//var s:string;
begin
ini:=Tinifile.create(AppDir+'LanExplorer.ini');
if not fileexists('LanExplorer.ini')
then
begin
ini.writeInteger('window position','top',top);
ini.writeInteger('window position','left',left);
ini.writeInteger('window position','width',width);
ini.writeInteger('window position','height',height);
ini.writeInteger('panel position','left_panel',LeftPanel.Width);
ini.writeInteger('panel position','right_panel',RightPanel.Width);
ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);
ini.writeString('Dock','RightDockPanel','alRight');
//ini.writeString('IP','IP2',Edit2.Text);
end
else
begin
top:=ini.ReadInteger('window position','top',50);
left:=ini.ReadInteger('window position','left',50);
width:=ini.ReadInteger('window position','width',500);
height:=ini.ReadInteger('window position','height',50);
if (width=screen.Width)and(height=screen.Height)then WindowState:=wsMaximized;
LeftPanel.Width:=ini.ReadInteger('panel position','left_panel',LeftPanel.Width);
RightPanel.Width:=ini.ReadInteger('panel position','right_panel',RightPanel.Width);
BottomPanel.Height:=ini.ReadInteger('panel position','bottom_panel',BottomPanel.Height);
end;
ini.Free;
end;
procedure TMainForm.SaveIni;
begin
if AppDir[1]='/' then exit; //open on the LAN
//showmessage(mydir);
ini:=Tinifile.create(AppDir+'LanExplorer.ini');
ini.writeInteger('window position','top',top);
ini.writeInteger('window position','left',left);
ini.writeInteger('window position','width',width);
ini.writeInteger('window position','height',height);
ini.writeInteger('panel position','left_panel',LeftPanel.Width);
ini.writeInteger('panel position','right_panel',RightPanel.Width);
ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);
{if RightDockPanel.HostDockSite = LeftPanel then
ini.writeString('Dock','RightDockPanel','alLeft')
else if RightDockPanel.HostDockSite = RightPanel then
ini.writeString('Dock','RightDockPanel','alRight')
else if RightDockPanel.HostDockSite = BottomPanel then
begin
if (RightDockPanel.Top<>BottomDockPanel.Top) then
ini.writeString('Dock','RightDockPanel','alBottomTop')
else ini.writeString('Dock','RightDockPanel','alBottomRight');
end;}
//ini.writeString('IP','IP2',Edit2.Text);
ini.Free;
end;