我正在尝试使用 Inno Setup 的 Pascal 脚本从 Windows 注册表(在本例中为 Google Sketchup)获取应用程序的安装目录,以便我可以在那里安装插件。
注册表项没有名称,在 Regedit 中只有“(默认)”。
我试过这个:
RegQueryStringValue( HKLM, 'SOFTWARE\Google\Google Sketchup 6', '(Default)', pluginLoc );
但它没有返回值。有什么建议吗?
最佳答案
只需将 SubKeyName
留空,如下所示:
[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;
底层 API 调用的匹配文档适用于 RegQueryValueEx() ,其中指出:
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.
关于windows - 当值仅使用默认名称时,如何在 Inno Setup 中获取注册表值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/913938/