当值仅使用默认名称时,如何在Inno Setup中获取注册表值? [英] How do I get a registry value in Inno Setup when the value only uses the default name?
问题描述
我正在尝试使用Inno Setup的Pascal脚本从Windows注册表(在本例中为Google Sketchup)中获取应用程序的安装目录,以便在此安装插件.
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.
注册表项没有名称,在Regedit中只有(默认)".
The registry key doesn't have a name, it just has "(Default)" in Regedit.
我尝试过:
RegQueryStringValue( HKLM, 'SOFTWARE\Google\Google Sketchup 6', '(Default)', pluginLoc );
,但不返回值.有什么建议吗?
but it doesn't return a value. Any suggestions?
推荐答案
只需将SubKeyName
留空,就像这样:
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.
如果lpValueName为NULL或空字符串",则该函数将检索键的未命名或默认值(如果有)的类型和数据.
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.
这篇关于当值仅使用默认名称时,如何在Inno Setup中获取注册表值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!