windows - 当值仅使用默认名称时,如何在 Inno Setup 中获取注册表值?

标签 windows registry inno-setup pascal

我正在尝试使用 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/

相关文章:

c++ - 在 Windows 中限制帧速率

windows - 如何在 Windows 上安装和使用 cURL?

c# - 回调函数在构建和 DLL 时有何用处

java - 如何在 Java 中解压缩目录中的所有 Zip 文件夹?

windows-7 - 从应用程序内访问 Win 7 上的 HKLM 注册表分支

python - innosetup 创建的可执行文件中出现 "Failed to execute script"错误

inno-setup - 如何禁用 Inno Setup 中向导表单上的 "Next"按钮?

Windows 卸载程序未以管理员身份运行

检查当前用户是否可以写入注册表(C,windows)

inno-setup - Inno Setup 重启后需要管理员登录才能完成