Reading the GUID value stored in the registry

I am trying to read a GUID value stored as a value binaryin a registry in Delphi. When I read it with BintoHex, but the result is in reverse order. It seems like I have to change bytes, but I thought BinToHex would do it.

I referred to this topic, but I can’t find the right solution: how to convert an array of bytes to a hexadecimal representation in Delphi It seems that this is due to a small event.

Below you can see the GUID stored in the registry

Here is my code:

var
s : string;
buffer : pointer;
...

begin
getmem(buffer, 1024*1024);
....
reg.ReadBinaryData(iValueOfregistry, buffer^, 1024*1024);
....
bintohex(pointer(longint(buffer)+14), PChar(s), 32);

Output for s: 90E24D373F126545916439C4925E467B

GUID must be FOLDERID_Downloads GUID:
{374DE290-123F-4565-9164-39C4925E467B}

Please, help Here

+5
1

GUID . , Delphi - TGUID.

, , TGUID, . , GUIDToString.

var
  GUID: TGUID;
  strGUID: string;
....
GUID := PGUID(PAnsiChar(buffer)+14)^;
strGUID := GUIDToString(GUID);

. TGUID:

TGUID = packed record
  D1: LongWord;
  D2: Word;
  D3: Word;
  D4: array[0..7] of Byte;
end;

. D1, D2 D3 . , 4 , D1. D2, D3. , 8 GUID .

, , , , GUID GUID.

+8

All Articles