Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 403
kraryal Avatar asked May 27 '09 04:05

kraryal


People also ask

What is default value of registry key?

What used to be called simply “the value of a registry key” (for since there was only one, there was no need to give it a name) now goes by the special name the default value: It's the value whose name is null. There's nothing particularly special about the default value aside from its unusual name.

What is registry name value?

Registry values are name/data pairs stored within keys. Registry values are referenced separately from registry keys. Each registry value stored in a registry key has a unique name whose letter case is not significant.

What are the three types of values in which stored in the registry?

The values contain the actual information stored in the Registry. There are three types of values; String, Binary, and DWORD - the use of these depends upon the context.


1 Answers

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.

like image 118
mghie Avatar answered Dec 05 '22 23:12

mghie