WIX:如何将应用程序注册到URL协议?

10
在WiX中,您可以轻松注册文件类型:
<ProgId Id="MyApp.File" Description="MyApp File" Icon="MyAppEXE" IconIndex="0">
  <Extension Id="ext" ContentType="application/x-myapp-file">
    <Verb Id="open" Command="&amp;Open" TargetFile="MyAppEXE" Argument="&quot;%1&quot;"/>
  </Extension>
</ProgId>
如果我想要注册一个URL协议,如这里所述,该怎么办?显然,它没有扩展名,那么我应该把Verb标签放在哪里呢?还是应该使用另一种方法?
谢谢。
2个回答

24

只需添加@ Yan Sklyarenko答案的代码:

<Component Id="ProductComponent" Guid="{206C911C-56EF-44B8-9257-5FD214427965}">
           <File Source="$(var.MyMainProgram.TargetPath)" />
           <RegistryKey Root="HKCR"
                 Key="protocolname"
                 Action="createAndRemoveOnUninstall">
             <RegistryValue Type="string" Name="URL Protocol" Value=""/>
             <RegistryValue Type="string" Value="URL:name of the protocol"/>
             <RegistryKey Key="DefaultIcon">
               <RegistryValue Type="string" Value="MyMainProgram.exe" />
             </RegistryKey>
             <RegistryKey Key="shell\open\command">
               <RegistryValue Type="string" Value="&quot;[INSTALLFOLDER]MyMainProgram.exe&quot; &quot;%1&quot;" />
             </RegistryKey>
           </RegistryKey>
         </Component>
  • MyMainProgram 是 Wix 安装项目中我主要项目的引用
  • protocolname 是 URL 中使用的协议的名称:protocolname://
  • name of the protocol 是该协议的正式名称

5

我怀疑在WiX中没有开箱即用的功能(可能在3.6版本中有?),但就我所看到的链接,注册URL协议的过程是将一堆条目添加到系统注册表中。因此,您可以手动添加RegistryKey / RegistryValue元素来模拟此过程。


谢谢!我相信这是正确的方法。最直接的解决方案是从注册表中导出一个有效的协议条目,然后通过heat.exe运行它。这将生成必要的RegistryKey/RegistryValue元素。 - l33t
1
我知道这是一个老问题,但你有任何使用Wix代码的例子吗?谢谢。 - Jérémie Bertrand
@JérémieBertrand,那只是我脑海中的一个想法,当时手头没有代码示例。 - Yan Sklyarenko

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接