Ich verwende dafür nen Variant, das geht auch wunderbar
Delphi-Quellcode:
function Config(Section, Value: String; Default: Variant; Typ: String = 'V'): Variant; Overload;
var
Read : Variant;
ReadInt : Integer;
begin
// Einen Konfigurationswert zurückgeben...
if (Typ <> 'R') then Read := CfgValues.Values[Section + '_' + Value];
if (Typ = 'R') then
begin
Read := CfgRegExp.Values[Section + '_' + Value];
if not (Read <> '') then Read := Default;
if not (Read <> '') then Read := '$';
Result := Read;
end;
if ((Typ = 'V') or (Typ = 'S')) then
begin
if not (Read <> '') then Read := Default;
Result := Read;
end;
if (Typ = 'B') then
begin
Result := Default;
if (Read = '1') then Result := True;
if (Read = '0') then Result := False;
end;
if (Typ = 'I') then
begin
if not (TryStrToInt(Read, ReadInt)) then Result := Default
else Result := ReadInt;
end;
end;
Edit: Es gibt die Funktion nochmal deswegen der Overload...
Delphi-Quellcode:
function Config(Section, Value: String; Typ: String = 'V'): Variant; Overload;
begin
Result := Config(Section, Value, '', Typ);
end;