Jo, danke klappt:
Der funktionierende Code:
Delphi-Quellcode:
TSettings=class(Tcomponent)
private
fs:string;
fi:Integer;
published
property s:string read fs write fs;
property i:integer read fi write fi;
public
procedure SaveConfig;
procedure ReadConfig;
end;
var
Form1: TForm1;
Settings:TSettings;
implementation
{$R *.dfm}
procedure TSettings.SaveConfig;
begin
WriteComponentResFile(extractfilepath(ParamStr(0)) + 'Settings.dat',Self);
end;
procedure TSettings.ReadConfig;
begin
if fileexists(extractfilepath(ParamStr(0)) + 'Settings.dat') then
try
Self := TSettings(ReadComponentResFile(extractfilepath(ParamStr(0)) + 'Settings.dat', Self));
except
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Settings:=TSettings.Create(self);
Settings.s:='hallo ich bins';
Settings.i:=15;
Settings.SaveConfig;
Settings.Free;
Settings:=TSettings.Create(self);
Settings.ReadConfig;
ShowMessage(settings.s);
ShowMessage(inttostr(Settings.i));
Settings.Free;
close;
end;
Tschüss
Alexander