如何使用 WiX 安装程序将应用程序与现有文件类型相关联? [英] How to associate application with existing file types using WiX installer?

查看:17
本文介绍了如何使用 WiX 安装程序将应用程序与现有文件类型相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相关:如何注册文件类型/extensions 与 WiX 安装程序? 但不是重复的.

Related to this: How to register file types/extensions with a WiX installer? but not a duplicate.

我需要处理现有的文件类型(.jpg 文件).

I need to handle existing file types (.jpg files).

我不希望我的应用成为 .jpg 的默认处理程序.我只想使用指向我的应用的链接扩展打开方式"菜单.

I do not want my app to be the default handler for .jpg. I would just like to extend the "Open with" menu with a link to my app.

我在注册表中看到 HKCR.jpgOpenWithListHKCR.jpgOpenWithProgIds 但我不确定是否要写入这些以及如何写入使用 WiX 正确执行此操作.我应该使用这样的东西吗?

I see HKCR.jpgOpenWithList and HKCR.jpgOpenWithProgIds in the registry but I am not sure whether to write to these and how to do it correctly with WiX. Should I use something like this?

<ProgId Id='??what here?' Description='Jpeg handled by my App'>
  <Extension Id='jpg' ContentType='image/jpeg'>
    <Verb Id='openwithmyapp' Sequence='10' Command='OpenWithMyApp' Target='[!FileId]' Argument='"%1"' />
  </Extension>
</ProgId>

这里有很多失败的方法(就像 Photo Mechanics 所做的那样,在我安装了这个软件后,图像文件类型的 HKCR 真的一团糟).

There are many ways to fail here (like Photo Mechanics did, the HKCR for image file types is a real mess after I have installed this software).

如何使用 WiX 正确执行此操作?

How to do this correctly with WiX?

推荐答案

这是一个完整、完整的示例,与链接问题相比,它的代码更详细、代码更简洁,应该会提供更好的答案.非常及时,因为我最近完成了之前发布的代码的移植,以使用正确的 ProgId 元素,所以这在我的脑海中是新鲜的 ;)

Here's a full, complete example with a bit more detail and cleaner code than in the linked question and should provide a better answer. Quite timely as I've recently finished porting the code posted previously, to use proper ProgId elements so this is fresh in my mind ;)

关于这里有什么",您几乎可以使用任何您喜欢的东西:)

In regards to the 'what here', you can pretty much use whatever you like :)

<Icon Id="filetype.ico" SourceFile="filetype.ico" />
<Component Id="MyApp.exe" Directory="APPLICATIONFOLDER" Guid="*">
    <File Id="MyApp.exe" Name="MyApp.exe" KeyPath="yes"/>

    <Shortcut Id="startmenuShortcut" Directory="ProgramMenuFolder" Name="MyApp" Icon="$(var.product).ico" IconIndex="0" WorkingDirectory="APPLICATIONFOLDER" Advertise="yes" />

    <!-- Capabilities keys for Vista/7 "Set Program Access and Defaults" -->
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilities" Name="ApplicationDescription" Value="!(loc.ApplicationDescription)" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilities" Name="ApplicationIcon" Value="[APPLICATIONFOLDER]MyApp.exe,0" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilities" Name="ApplicationName" Value="!(loc.ApplicationName)" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilitiesDefaultIcon" Value="[APPLICATIONFOLDER]MyApp.exe,1" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilitiesFileAssociations" Name=".xyz" Value="MyApp.Document" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilitiesMIMEAssociations" Name="application/xyz" Value="MyApp.Document" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMyAppCapabilitiesshellOpencommand" Value="&quot;[APPLICATIONFOLDER]MyApp.exe&quot; &quot;%1&quot;" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARERegisteredApplications" Name="MyApp" Value="SOFTWAREMyAppCapabilities" Type="string" />

    <!-- App Paths to support Start,Run -> "myapp" -->
    <RegistryValue Root="HKLM" Key="SOFTWAREMicrosoftWindowsCurrentVersionApp PathsMyApp.exe" Value="[!MyApp.exe]" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREMicrosoftWindowsCurrentVersionApp PathsMyApp.exe" Name="Path" Value="[APPLICATIONFOLDER]" Type="string" />

    <!-- Extend to the "open with" list + Win7 jump menu pinning  -->
    <RegistryValue Root="HKLM" Key="SOFTWAREClassesApplicationsMyApp.exeSupportedTypes" Name=".xyz" Value="" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREClassesApplicationsMyApp.exeshellopen" Name="FriendlyAppName" Value="!(loc.ApplicationName)" Type="string" />

    <!-- MyApp.Document ProgID -->
    <RegistryValue Root="HKLM" Key="SOFTWAREClassesMyApp.Document" Name="FriendlyTypeName" Value="!(loc.DescXYZ)" Type="string" />
    <ProgId Id="MyApp.Document" Description="!(loc.DescXYZ)" Icon="filetype.ico" Advertise="yes">
        <Extension Id="xyz">
            <Verb Id="open" Command="!(loc.ExplorerMenuOpenXYZ)" Argument="&quot;%1&quot;" />
            <MIME Advertise="yes" ContentType="application/xyz" Default="yes" />
        </Extension>
    </ProgId>

    <!-- Optional: add an 'Edit with XYZ' to 'right click' even when not associated -->
    <RegistryValue Root="HKLM" Key="SOFTWAREClassesSystemFileAssociations.xyzshelledit.MyApp.exe" Value="!(loc.ExplorerMenuEditXYZ)" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWAREClassesSystemFileAssociations.xyzshelledit.MyApp.execommand" Value="&quot;[APPLICATIONFOLDER]MyApp.exe&quot; &quot;%1&quot;" Type="string" />
</Component>

这篇关于如何使用 WiX 安装程序将应用程序与现有文件类型相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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