Inno Setup不允许访问所有注册表项,为什么? [英] Inno Setup doesn't allow access to all registry keys, why?

查看:119
本文介绍了Inno Setup不允许访问所有注册表项,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码来知道密钥是否存在:

I use this code to know if a key exists or not:

if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Autodesk') then
begin
  MsgBox('Key exists!!', mbInformation, MB_OK);
end;

在此示例中,它可以工作,我有消息框,但此操作不起作用:

for this example, it works, I have the message box, but with this it doesn't:

if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Autodesk\Maya') then
begin
  MsgBox('Key exists!!', mbInformation, MB_OK);
end;

但是Maya键在我的计算机上存在.有人可以帮我吗?

But the Maya key exists on my computer. Can anybody help me?

实际上,似乎Inno Setup无法访问正确的键...
例如,使用此代码,我列出了HKEY_LOCAL_MACHINE\SOFTWARE的所有子项,但是(!)结果是HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node的所有子项...

In fact, it seems that Inno Setup don't access to the right keys...
For example, with this code I list all the subkeys of HKEY_LOCAL_MACHINE\SOFTWARE, but (!) the result is all subkey of HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node ...

if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, 'SOFTWARE', Names) then
begin
  S := '';
  for I := 0 to GetArrayLength(Names)-1 do
    S := S + Names[I] + #13#10;
  MsgBox('List of subkeys:'#13#10#13#10 + S, mbInformation, MB_OK);
end;

为什么要使用Wow6432Node键?

推荐答案

这根本不是Inno Setup的错. 注册表在Vista和更高版本中已虚拟化,并且在64位上,有

It's not Inno Setup's fault at all; the Registry is virtualized in Vista and higher, and on 64-bit there are branches for native 64-bit and WOW'ed 32-bit.

在这种情况下,由于Inno Setup是32位程序,因此操作系统会将其所有HKLM\Software注册表请求都定向到WOW6432Node.

In this case, since Inno Setup is a 32-bit program, the OS directs all of its HKLM\Software registry requests to the WOW6432Node.

要在安装程序中处理注册表虚拟化,可以专门使用x86和x64密钥根.例如,当需要区分时,在[Registry]部分中使用HKLM32HKLM64.在[Code]部分中,在if IsWin64块中使用HKLM64包装注册表帮助器函数调用.

To handle the registry virtualization in your installer, you can specifically use x86 and x64 key roots. For example, use HKLM32 or HKLM64 in your [Registry] section when you need to differentiate. In [Code] section, wrap registry helper function calls using HKLM64 in an if IsWin64 block.

无论安装程序是否已声明为x64安装程序,此示例都可以在我们的安装程序中正常运行.

This example works ok from our installer, whether or not the installer is declared as an x64 installer.

function Mobu120x64IsAvailable(): Boolean;
var
  resultString: String;
begin
  resultString := 'No';
  if IsWin64 then
  begin
    Result := RegValueExists(HKLM64, 'SOFTWARE\Autodesk\MotionBuilder\2012', 'InstallPath');
    if Result then begin
      resultString := 'Yes';
    end;
    Log('Win64: Found Mobu 12.0 for x64?:' + resultString);
  end;
end;

这篇关于Inno Setup不允许访问所有注册表项,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆