How do I get a registry value in Inno Setup when the value only uses the default name?

24,930

Just leave the SubKeyName empty, like so:

[Code]
function InitializeSetup(): Boolean;
var
  V: string;
begin
  if RegQueryStringValue(HKLM, 'SOFTWARE\Google\Google Sketchup 6', '', V) then
    MsgBox('Value is "' + V + '"', mbInformation, MB_OK);
  Result := TRUE;
end;

The matching documentation for the underlying API call is for RegQueryValueEx(), which states:

The name of the registry value.

If lpValueName is NULL or an empty string, "", the function retrieves the type and data for the key's unnamed or default value, if any.

Share:
24,930
kraryal
Author by

kraryal

Updated on February 14, 2020

Comments

  • kraryal
    kraryal about 4 years

    I'm trying to get the install directory of an application from the Windows Registry (Google Sketchup in this case) with Inno Setup's Pascal scripting so I can install a plugin there.

    The registry key doesn't have a name, it just has "(Default)" in Regedit.

    I tried this:

    RegQueryStringValue( HKLM, 'SOFTWARE\Google\Google Sketchup 6', '(Default)', pluginLoc );
    

    but it doesn't return a value. Any suggestions?

  • Maxence
    Maxence over 8 years
    It is the ValueName, not the SubKeyName which need to be empty.