delphi ini读写

uses  IniFiles;
//写
procedure TForm1.Button1Click(Sender: TObject);
var
  ZkyFileIni: TIniFile;
  ZkyIniAdd: string;
begin
  ZkyIniAdd := GetCurrentDir + '\test.ini';
  ZkyFileIni := TIniFile.Create(PChar(ZkyIniAdd));
  ZkyFileIni.WriteString('ZkyJD_2', 'Zkykong', 'a123');
  ZkyFileIni.free();
end;
//读
procedure TForm1.Button2Click(Sender: TObject);
var
  ZkyFileIni: TIniFile;
  ZkyStrIni: string;
  ZkyIniAdd: string;
begin
  Memo1.Lines.Clear;
  ZkyIniAdd := GetCurrentDir + '\test.ini';
  ZkyFileIni := TIniFile.Create(PChar(ZkyIniAdd));
  ZkyStrIni := ZkyFileIni.ReadString('ZkyJD_2', 'Zkykong', 'ss');
  Memo1.Lines.Add(PChar(ZkyStrIni));
  ZkyFileIni.free();
end;

你可能感兴趣的:(delphi)