[Solved] ReadBinaryData can't read DigitalProductId lazarus / 34-Windows ---------------------------------------------------------------------- TheLastCayen · 2017-04-05 19:08 Hi. I am using Windows 7 64 bit Lazarus 1.6 FPC 3.0.0 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TForm1.Button1Click(Sender: TObject);var  CompileCommand: string='';  Registry: TRegistry;  ms: TMemoryStream;begin  Registry := TRegistry.Create;  ms := TMemoryStream.Create;  Memo1.Lines.Clear;  try    Registry.RootKey := HKEY_LOCAL_MACHINE;    if Registry.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows NT\CurrentVersion\') then      begin        Memo1.Lines.Add(Registry.ReadString('ProductName'));        Memo1.Lines.Add(Registry.ReadString('EditionID'));        Memo1.Lines.Add(Registry.ReadString('BuildLab'));        Memo1.Lines.Add(Registry.ReadString('CurrentType'));        ms.Size:=Registry.GetDataSize('DigitalProductId');        Registry.ReadBinaryData('DigitalProductId',ms.Memory^, ms.Size);      Memo1.Lines.Add(DecodeProductKey(ms.ReadByte));       end;   finally    Registry.Free;    ms.free;  end;   Compiler can compile the code but when I execute it as normal user and administrator, I get this error message: Failed to get data for value "DigitalProductId". I know DigitalProductId exist in the registry but I don't know if this is an issue with my code or a weird windows security feature but "Registry.ReadBinaryData('DigitalProductId',ms.Memory^, ms.Size); " seem to be the problem. Thank you ---------------------------------------------------------------------- ASerge · 2017-04-05 20:02 Size for DigitalProductId4, but read DigitalProductId. ---------------------------------------------------------------------- TheLastCayen · 2017-04-06 14:49 Quote from: ASerge on April 05, 2017, 10:02:03 pmSize for DigitalProductId4, but read DigitalProductId. Thank you , good catch but that was only the result of previous test. I tried to read the other key with the same result. I fix the code and I still have the same error message. Any other recommendation ? ---------------------------------------------------------------------- TheLastCayen · 2017-04-06 15:28 I upgrade to Lazarus: 1.6.4 FPC: 3.0.2 And now my code is working. Thank you