使用 WiX 工具集创建文件关联

Creating file association with WiX Toolset

我创建了一个可以打开图像文件的应用程序。现在我正在使用 WiX 工具集创建安装程序。在过去的几天里,我陷入了一些误解:试图注册我的应用程序并将其与所需的扩展相关联。一切都出现在注册表中,但 none 我的文件随我的应用程序一起打开,就好像它没有安装一样。

这是我描述可执行文件并为其注册所有扩展的部分:

<Component Id="CmpLightImageViewer.exe" Guid="{...}">
  <File Id="MainExe" Name="LightImageViewer.exe" />
</Component>

<Component Id="CmpLightImageViewerProgId" Guid="{391FBC30-B5A1-4AB7-8FA4-254C1CE2BF69}" KeyPath="yes">
  <ProgId Id="LightImageViewerSvg" Description="Light image viewer">
    <Extension Id="svg">
      <Verb Id="open" TargetFile="MainExe" Argument="&quot;%1&quot;" />
    </Extension>
  </ProgId>
  <ProgId Id="LightImageViewerGif" Description="Light image viewer">
    <Extension Id="gif">
      <Verb Id="open" TargetFile="MainExe" Argument="&quot;%1&quot;" />
    </Extension>
  </ProgId>
...
</Component>

这就是我在注册表 HKCR 中看到的内容。在 HKCU/Software/Classes 中相同,但在 HCLM/Software/Classes 中不同:

我错过了什么?我还需要做什么才能让它发挥作用?虽然我可以使用 Windows 工具为每种类型手动设置文件关联,但这不是我希望它工作的方式。

我正在使用 wix3.10

在 windows10 中使用 vs2015 构建它

这是 Vista 中启动的一种安全功能 - Windows 保护 "default" 关联,允许用户 select 它们。如果您希望您的程序成为 "default" 来处理 现有 文件类型,从而 覆盖用户设置 (这正是这个功能据我所知,应该可以防止),那么你可以看看这个问题的例子:

How to associate application with existing file types using WiX installer?

我可以看到写入注册表的数据存在潜在问题。 由于多余的引号,该路径似乎是错误的。 您的路径应该如下所示:

"C:\Program Files (x86)\LightImageViewer\LightImageViewer.exe %1"