unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, inifiles, StdCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create( ChangeFileExt( Application.ExeName, '
.INI' ) );
try
ini.WriteString('
[NAME]', '
Hans', '
Peter');
//String wird geschrieben
finally
Ini.Free;
end
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
var ini : TiniFile;
//ini variable
begin
ini := TiniFile.Create(ExtractFilePath(ParamStr(0))+'
bin/'+'
config.ini');
//ini erstellen
try
begin
Edit1.Text := ini.ReadString('
NAME', '
Hans', '
');
//String wird ausgelesen und in Edit eingetragen
end;
finally
ini.free;
end;
end;
end.