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

l33*_*33t 8 url protocols wix wix3.5

在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>
Run Code Online (Sandbox Code Playgroud)

如果我想怎么注册的URL协议,按规定在这里?显然,它没有扩展,所以我在哪里放Verb标签?或者我应该使用另一种方法?

谢谢.

Jér*_*and 12

只是添加@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>
Run Code Online (Sandbox Code Playgroud)
  • MyMainProgram 是对我在wix安装项目中的主项目的引用
  • protocolname 是url中使用的协议的名称: protocolname://
  • name of the protocol 是协议的正式名称


Yan*_*nko 5

我怀疑 WiX 中是否有一个开箱即用的功能(可能在 3.6 中?),但据我所见,通过您提供的链接,注册 URL 协议的过程正在添加一堆条目到系统注册表。因此,您可以手动添加 RegistryKey/RegistryValue 元素来模拟这一点。