Question

I am trying to read the Machine GUID from the Windows registry using Inno setup pascal scripting function RegQueryStringValue. The registry key I am after is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid

procedure StoreHwID();
    var
    HwId: String;

begin
   RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Cryptography','MachineGuid', HwId);
   MsgBox('Value is "' + HwId + '"', mbInformation, MB_OK);
end;

This fails to set a value in the HwId variable.

What am I missing?

Was it helpful?

Solution

InnoSetup is a 32 bit process. If you are running on a 64 bit OS, you need to specify the 64 bit registry by using HKEY_LOCAL_MACHINE_64 rather than HKEY_LOCAL_MACHINE. You might need to have two RegQueryStringValue calls. One for 64 bit and one for 32 bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top