delphi(配置文件)

procedure TFileCopy.ReadIniFile();
var
Inifile: TIniFile;
begin
   IniFile:=TIniFile.Create('files.ini');
   if IniFile = nil then
   begin
     exit;
   end;
   Inifile.ReadString('top1','src',edtSrces.Text);  //top1  标签名-段名    edtsrces.Test-要存的string
   Inifile.ReadString('top1','des',edtDest.Text);
   Inifile.ReadString('top1','types',edtTypes.Text);
   Inifile.Free;
end;
procedure TFileCopy.WriteIniFile();
var
Inifile: TIniFile;
begin
  IniFile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'files.ini');
   if IniFile = nil then
   begin
     ShowMessage('打开ini失败');
     exit;
   end;
  if edtSrces.Text<>'' then
      Inifile.WriteString('top1','src',edtSrces.Text);
   if edtDest.Text<>'' then
      Inifile.WriteString('top1','dest',edtDest.Text);
   if edtTypes.Text<>'' then
      Inifile.WriteString('top1','types',edtTypes.Text);
   Inifile.Destroy;

end;

你可能感兴趣的:(delphi)