Using Regedit to check the value type this type is shown as REG_MULTI_SZ
When you modify it with REGEDIT , it shows a "Edit Binary Value"
TRegistry.ReadBinaryData fails with an error, "this datatype is in correct"
TRegistry.DataTypes are listed as rdUnknown, rdBinary, rdExpandString,
rdString and rdInteger
is there a workaround for Delphi 2 ?
Thanks
Russ
Since the datatype shouldn't matter when reading, I guess
it is the TRegistry class that causes this trouble.
If you could try the function below, and and already have
a TRegistry instance, you can pass it the TRegistry.CurrentKey
as the "aKey" parameter. (Example at bottom of msg.)
{--------------------}
function Reg_ReadMultiSz(aKey: HKEY; const aValueName: string;
aStrings: TStrings): Boolean;
var
DataType,
DataSize: Longword;
Data: Pointer;
P: PChar;
begin
Result := RegQueryValueEx(aKey, PCHAR(aValueName), NIL, @DataType,
NIL, @DataSize) = ERROR_SUCCESS;
if Result then
begin
GetMem(Data, DataSize);
try
Result := RegQueryValueEx(aKey, PCHAR(aValueName), NIL, NIL,
Data, @DataSize) = ERROR_SUCCESS;
if Result then
begin
aStrings.Clear;
P := Data;
while P^ <> #0 do
begin
AStrings.Append(P);
Inc(P, StrLen(P) + 1);
end;
end;
finally
FreeMem(Data);
end;
end;
end;
{--------------------}
Usage example:
procedure TForm1.Button1Click(Sender: TObject);
var
List: TStringList;
begin
List := TStringList.Create;
try
with TRegistry.Create do
try
{ Change these registry entries
to your own suitable values }
RootKey := HKEY_CURRENT_USER;
OpenKeyReadOnly('software\company\application');
Reg_ReadMultiSz(CurrentKey, 'some_multisz_value', List);
finally
CloseKey;
Free;
end;
ShowMessage(List.Text);
finally
List.Free;
end;
end;
{-----}
HTH
Regards
-ThomasN
Russ
"Thomas Nelvik" <thomas...@chello.no> wrote in message
news:3b3f53b4_2@dnews...