Inno Setup refers to a registry key containing curly braces using the constant {reg}

I'm trying to use the constant {reg} for the DefaultDirName where it refers to a path that contains curly braces:

  DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3E4A76D9-EC0E-4806-915C-8BC2B3C0011B},InstallLocation}

      

However, this does not work because the compiler assumes that the GUID in the path is constant. If I try and remove the brace with the other brace as suggested (see below), that doesn't work either and gives the "Invalid registry error" error.

  DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{3E4A76D9-EC0E-4806-915C-8BC2B3C0011B},InstallLocation}

      

I have tried every combination I can think of to try and avoid this and get the compiler to recognize it, including using% 7d to try and lock the closing shape as suggested in the documentation, but that doesn't seem to compile to the closing curly brace in this situation. Hopefully someone can advise on how to get the compiler to recognize this location in the registry, or at least tell me if I'm trying to do something that isn't possible. If so, is there any other way to do this? Considering I've already tried:

  DefaultDirName={code:GetExistingInstallPath}
  [Code]
  function GetExistingInstallPath(Param: String): String;
  begin
    RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F34A6950-7E0E-4F92-8B0E-C552F4989DA}',
'InstallLocation', strExistingInstallPath);
    Result := strExistingInstallPath;
  end;

      

which compiles but strExistingInstallPath returns nothing and hangs over {code: GetExistingInstallPath} returns "Exception: Unable to evaluate 'code' due to possible side effects". After a couple of hours trying to get this to work, I'm getting close to finding that Inno Setup does not support registry locations containing curly braces.

Note that I need to read this registry key as the program was not installed by Inno Setup and this is a file replacement patch, so I need to know where it was originally installed.

+3


source to share


1 answer


In case of use, {reg:...}

instead of closing, }

you should use%7d

Example:

DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
{{‌​3E4A76D9-EC0E-4806-915C-8BC2B3C0011B%7d,InstallLocation}

      

When reading Registy in a section [Code]

, if using NO ExpandConstant

, you don't need to use double open{{



Example:

RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
{3E4A76D9-EC0E-4806-915C-8BC2B3C0011B}','InstallLocation', strExistingInstallPath);

      

PS Thanks @Tlama for pointing out my inaccuracy.

+3


source







All Articles