32

我编写了一个与 Windows XP 完美配合的 WiX 安装程序,但是在安装到 Windows 7 机器时,我遇到了注册表项的困难。我需要添加一个 HKLM 条目以及该程序的注册表条目以显示在开始菜单中。这是我用于两种条目的代码:

<!-- Create the registry entries for the program -->
<DirectoryRef Id="TARGETDIR">
  <Component Id="RegistryEntriesInst" Guid="...">
    <RegistryKey Root="HKLM"
                 Key="Software\$(var.Manufacturer)\$(var.ProductName)"
          Action="createAndRemoveOnUninstall">
      <RegistryValue
          Type="string"
          Name="installed"
          Value="true"
          KeyPath="yes"/>
    </RegistryKey>
  </Component>
  <Component Id="RegistryEntriesVer" Guid="...">
    <RegistryKey Root="HKLM"
                 Key="Software\$(var.Manufacturer)\$(var.ProductName)"
          Action="createAndRemoveOnUninstall">
      <RegistryValue
          Type="string"
          Name="version"
          Value="$(var.ProductVersion)"
          KeyPath="yes"/>
    </RegistryKey>
  </Component>
</DirectoryRef>

<!-- To add shortcuts to the start menu to run and uninstall the program -->
<DirectoryRef Id="ApplicationProgramsFolder">
  <Component Id="ApplicationShortcut" Guid="...">
    <Shortcut Id="ApplicationStartMenuShortcut"
              Name="$(var.ProductName)"
              Description="..."
              Target="[SERVERLOCATION]$(var.Project.TargetFileName)"
              WorkingDirectory="SERVERLOCATION"/>
    <Shortcut Id="UninstallProduct"
                  Name="Uninstall $(var.ProductName)"
                  Description="..."
                  Target="[System64Folder]msiexec.exe"
                  Arguments="/x [ProductCode]"/>
    <RemoveFolder Id="SERVERLOCATION" On="uninstall"/>
    <RegistryValue
        Root="HKCU"
        Key="Software\$(var.Manufacturer)\$(var.ProductName)"
        Name="installed"
        Type="integer"
        Value="1"
        KeyPath="yes"/>
    </Component>
</DirectoryRef>

我该如何解决这个问题?

附带说明一下,Windows XP 和 Windows 7 计算机上的注册表权限是相同的。

4

3 回答 3

33

我已经弄清楚为什么会这样。

在 x86 平台上编译 WiX 安装程序后,Windows 7 将其选为具有 32 位注册表项的 32 位安装程序。Windows 7 64 位通过执行我所看到的操作来处理 32 位注册表项。

该程序仍在注册;它只是不在注册表的 64 位部分中。在 x64 平台下编译它,同时进行必要的更改以使其适用于 64 位系统(ProgramFileFolder 变为 ProgramFiles64Folder 等),它将把东西放在正确的位置。

于 2009-12-10T19:28:35.360 回答
19

感谢您为我基本上解决了这个问题!

我只是想补充一点,您不一定需要将所有内容都更改为 x64 才能使其正常工作,只需将相关组件标记为 x64。

<Component Id="MyShellExtension64.dll" Guid="..." Win64="yes">
  <Condition>VersionNT64</Condition>
  <File
    Name="MyShellExtension64.dll"
    Source="MyShellExtension64.dll"
    KeyPath="yes"/>
  <RegistryValue
    Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved"
    Name="{GUID}" Value="My Shell Extension" Type="string"/>
</Component>

请注意Win64="yes",这是写入注册表的 64 位区域所需的全部内容。存在 VersionNT64 条件,因此该组件将仅安装在 x64 系统上。

就我而言,这会发出 ICE80 警告,因为我想在 32 位 ProgramFilesFolder 中安装 64 位组件。我很乐意忽略这些,因为我的主应用程序不是 x64,只有 shell 扩展是,而且我不想将 shell 扩展放在它自己的特殊文件夹中。

于 2010-04-05T07:33:31.267 回答
5

Windows 7 处理某些注册表项的方式存在一些差异。从 Windows 7 开始,注册表反射已被删除。我不确定这是否会影响您在此处看到的内容,但请查看此链接以获取更多信息。

此外,如果您使用的是 64 位版本的 Windows 7,您可能可以通过参考MSDN 64 位 Windows 编程指南深入了解一些细节。

此外,如果您需要根据 Windows 风格(XP、Vista、7 等)将不同的注册表项安装到不同的位置,那么这个 Stack Overflow 问题也可以为您提供答案。

于 2009-12-10T16:51:17.033 回答