use 添加 Registry,<br>我程序中用到的,参考一下!<br>//读出<br>procedure TFrmBak.FormShow(Sender: TObject);<br> function GetBackPath: string;<br> var<br> Reg: TRegistry;<br> begin<br> Reg := Tregistry.Create;<br> try<br> Reg.RootKey := HKEY_CURRENT_USER;<br> if Reg.OpenKey('/Software/LdcErpAcc/LDCDataBase', False) then<br> Result := Reg.ReadString('BackPath');<br> finally<br> Reg.closekey;<br> Reg.Free;<br> end;<br> end;<br>begin<br> StrOldBackPath := GetBackPath + DataBaseFrm.strdata;<br> dxButtonEdit1.text := GetBackPath + DataBaseFrm.strdata + FormatDateTime('yyyymmdd', Now) + '.dat';<br>end;<br>//写入<br>procedure TFrmBak.FormClose(Sender: TObject; var Action: TCloseAction);<br>var<br> Reg: TRegistry;<br> StrBackPath: string;<br> i: integer;<br>begin<br> i := length(StrRScan(pchar(Trim(dxButtonEdit1.text)), '/'));<br> StrBackPath := Copy(Trim(dxButtonEdit1.text), 1, (length(Trim(dxButtonEdit1.text)) - i + 1));<br> if (Trim(StrOldBackPath) <> StrBackPath) and (BBack = True) then<br> begin<br> Reg := TRegistry.Create;<br> try<br> Reg.RootKey := HKEY_CURRENT_USER;<br> if Reg.OpenKey('/Software/LdcErpAcc/LDCDataBase', False) = False then<br> begin<br> //如果注册表中没有信息则创建信息<br> reg.CreateKey('/Software/LdcErpAcc/LDCDataBase');<br> Reg.OpenKey('/Software/LdcErpAcc/LDCDataBase', True);<br> Reg.WriteString('BackPath', StrBackPath);<br> end;<br> if Reg.OpenKey('/Software/LdcErpAcc/LDCDataBase', False) then<br> Reg.WriteString('BackPath', StrBackPath);<br> finally<br> Reg.closekey;<br> Reg.free;<br> end;<br> end;<br>end;<br>