Delphi-Quellcode:
procedure Bla;
const
TestKey = 'Software\Microsoft\Windows\CurrentVersion\Explorer';
TestName = 'ShellState';
var
Buffer, Text: PAnsiChar;
BufferSize: Integer;
Reg: TRegistry;
begin
Buffer := nil;
Text := nil;
BufferSize := 0;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKeyReadOnly(TestKey) then begin
BufferSize := Reg.GetDataSize(TestName);
GetMem(Buffer, BufferSize);
GetMem(Text, BufferSize * 2);
try
Reg.ReadBinaryData(TestName, Buffer^, BufferSize);
BinToHex(Buffer, Text, BufferSize);
ShowMessage(Text);
finally
FreeMem(Text);
FreeMem(Buffer);
Reg.CloseKey;
end;
end else begin
ShowMessage(Format('Kann Key %s nicht öffnen', [TestKey]));
end;
finally
Reg.Free;
end;
end;
Allerdings garantiert dir niemand, dass sich der Inhalt zwischen dem Aufruf von Reg.GetDataSize und Reg.ReadBinaryData nicht ändert (?)
Dani H.
At Least I Can Say I Tried