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

发布于 2024-07-21 17:20:13 字数 299 浏览 4 评论 0原文

我正在尝试使用 Inno Setup 的 Pascal 脚本从 Windows 注册表(本例中为 Google Sketchup)获取应用程序的安装目录,以便我可以在那里安装插件。

该注册表项没有名称,在 Regedit 中只有“(默认)”。

我尝试了这个:

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

但它没有返回值。 有什么建议么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2024-07-28 17:20:13

只需将 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(),其中指出:

注册表值的名称。

如果 lpValueName 为 NULL 或空字符串“”,则该函数检索键的未命名或默认值(如果有)的类型和数据。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文