Home > Mobile >  Inno Setup: RegQueryStringValue isn't working
Inno Setup: RegQueryStringValue isn't working

Time:03-22

Using Inno Setup, I'm trying to check to see if the .NET 4.8 runtime is installed on a Windows computer. If it is not installed, I run the .NET 4.8 runtime installer exe file. According to Microsoft, you can check the registry at a certain location and look at a certain value to see which specific version of .NET is installed. Inno Setup has a function called RegQueryStringValue which grabs a value from the registry:

https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerystringvalue

I am following that API correctly, as far as I'm aware. I have also confirmed, using regedit, that this registry key and value do exist on my system. However, when I run Inno Setup, it fails to find the registry value. Here is my code:

function IsDotnet48Installed: boolean;
var
  valueStr: string;
  valueInt: integer;
begin
  if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', valueStr) then
  begin
    MsgBox('.NET 4.8 registry value is: "'   valueStr   '"', mbInformation, MB_OK);
    valueInt := StrToInt(valueStr);
    if valueInt >= 528040 then
      result := true
    else
      result := false
  end
else
  MsgBox('Unable to find .NET 4.8 registry key', mbInformation, MB_OK);
end;

When the above code is ran, the RegQueryStringValue function returns false, and I thus get the message box that says "Unable to find .NET 4.8 registry key". I am not sure what I am doing wrong.

Thank you.

CodePudding user response:

Inno Setup is 32-bit application. When accessing HKLM\SOFTWARE in 32-bit application, it gets redirected to HKLM\SOFTWARE\Wow6432Node.

If you want to read the 64-bit HKLM\SOFTWARE key, use HKEY_LOCAL_MACHINE_64 (HKLM64).

Or use 64-bit installation mode.


Related question: Writing 32/64-bit specific registry key in Inno Setup

CodePudding user response:

@LexiLi 's comment to the original question is the answer.

Instead of using the function RegQueryStringValue I used the function RegQueryDWordValue. Worked on the first try.

https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerydwordvalue

  • Related