mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-01-07 16:00:39 +01:00
* Patch from Stephano so TRegIniFile can process registry values written by Delphi
git-svn-id: trunk@17206 -
This commit is contained in:
parent
ee461becfb
commit
bc2bebfa16
@ -83,30 +83,44 @@ procedure TRegIniFile.WriteBool(const Section, Ident: string; Value: Boolean);
|
||||
begin
|
||||
if not OpenKey(fPath+Section,true) then Exit;
|
||||
try
|
||||
inherited WriteBool(Ident,Value);
|
||||
finally
|
||||
CloseKey;
|
||||
if not fPreferStringValues then
|
||||
inherited WriteBool(Ident,Value)
|
||||
else begin
|
||||
if ValueExists(Ident) and (GetDataType(Ident)=rdInteger) then
|
||||
inherited WriteBool(Ident,Value)
|
||||
else
|
||||
inherited WriteString(Ident,BoolToStr(Value));
|
||||
end;
|
||||
finally
|
||||
CloseKey;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
|
||||
begin
|
||||
if not OpenKey(fPath+Section,true) then Exit;
|
||||
try
|
||||
inherited WriteInteger(Ident,Value);
|
||||
finally
|
||||
CloseKey;
|
||||
end;
|
||||
try
|
||||
if not fPreferStringValues then
|
||||
inherited WriteInteger(Ident,Value)
|
||||
else begin
|
||||
if ValueExists(Ident) and (GetDataType(Ident)=rdInteger) then
|
||||
inherited WriteInteger(Ident,Value)
|
||||
else
|
||||
inherited WriteString(Ident,IntToStr(Value));
|
||||
end;
|
||||
finally
|
||||
CloseKey;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
|
||||
begin
|
||||
if not OpenKey(fPath+Section,true) then Exit;
|
||||
try
|
||||
if not OpenKey(fPath+Section,true) then Exit;
|
||||
try
|
||||
inherited WriteString(Ident,Value);
|
||||
finally
|
||||
finally
|
||||
CloseKey;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
|
||||
@ -115,7 +129,10 @@ begin
|
||||
if not OpenKey(fPath+Section,false) then Exit;
|
||||
try
|
||||
if ValueExists(Ident) then
|
||||
Result := inherited ReadBool(Ident);
|
||||
if (not fPreferStringValues) or (GetDataType(Ident)=rdInteger) then
|
||||
Result := inherited ReadBool(Ident)
|
||||
else
|
||||
Result := StrToBool(inherited ReadString(Ident));
|
||||
finally
|
||||
CloseKey;
|
||||
end;
|
||||
@ -127,7 +144,10 @@ begin
|
||||
if not OpenKey(fPath+Section,false) then Exit;
|
||||
try
|
||||
if ValueExists(Ident) then
|
||||
Result := inherited ReadInteger(Ident);
|
||||
if (not fPreferStringValues) or (GetDataType(Ident)=rdInteger) then
|
||||
Result := inherited ReadInteger(Ident)
|
||||
else
|
||||
Result := StrToInt(inherited ReadString(Ident));
|
||||
finally
|
||||
CloseKey;
|
||||
end;
|
||||
|
||||
@ -130,8 +130,9 @@ type
|
||||
---------------------------------------------------------------------}
|
||||
TRegIniFile = class(TRegistry)
|
||||
private
|
||||
fFileName: String;
|
||||
fPath : String;
|
||||
fFileName : String;
|
||||
fPath : String;
|
||||
fPreferStringValues: Boolean;
|
||||
public
|
||||
constructor Create(const FN: string); overload;
|
||||
constructor Create(const FN: string;aaccess:longword); overload;
|
||||
@ -150,6 +151,8 @@ type
|
||||
procedure DeleteKey(const Section, Ident: String);
|
||||
|
||||
property FileName: String read fFileName;
|
||||
property PreferStringValues: Boolean read fPreferStringValues
|
||||
write fPreferStringValues;
|
||||
end;
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user