mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 06:29:42 +02:00
git-svn-id: trunk@29217 -
This commit is contained in:
parent
8508d25f8e
commit
3e24a9ebfd
@ -373,6 +373,7 @@ function TRegistry.ReadString(const Name: string): string;
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
Info : TRegDataInfo;
|
Info : TRegDataInfo;
|
||||||
|
ReadDataSize: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
GetDataInfo(Name,Info);
|
GetDataInfo(Name,Info);
|
||||||
@ -381,11 +382,19 @@ begin
|
|||||||
If Not (Info.RegData in [rdString,rdExpandString]) then
|
If Not (Info.RegData in [rdString,rdExpandString]) then
|
||||||
Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
|
Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
|
||||||
SetLength(Result,Info.DataSize);
|
SetLength(Result,Info.DataSize);
|
||||||
If StringSizeIncludesNull then
|
ReadDataSize := GetData(Name,PChar(Result),Info.DataSize,Info.RegData);
|
||||||
SetLength(Result, Info.DataSize-1)
|
if ReadDataSize > 0 then
|
||||||
|
begin
|
||||||
|
// If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type,
|
||||||
|
// the size includes any terminating null character or characters
|
||||||
|
// unless the data was stored without them! (RegQueryValueEx @ MSDN)
|
||||||
|
if StringSizeIncludesNull then
|
||||||
|
if Result[ReadDataSize] = #0 then
|
||||||
|
Dec(ReadDataSize);
|
||||||
|
SetLength(Result, ReadDataSize);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
SetLength(Result, Info.DataSize);
|
Result := '';
|
||||||
GetData(Name,PChar(Result),Info.DataSize,Info.RegData);
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
result:='';
|
result:='';
|
||||||
|
Loading…
Reference in New Issue
Block a user