如何使用WiX安装程序将应用程序与现有文件类型相关联?

Mar*_*rek 29 registry installer windows-installer file-type wix

与此相关:如何使用WiX安装程序注册文件类型/扩展名?但不是重复.

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

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

我看到HKCR\.jpg\OpenWithList\HKCR\.jpg\OpenWithProgIds\在注册表中,但我不确定是否写这些以及如何正确使用WiX.我应该使用这样的东西吗?

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

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

如何正确使用WiX?

sas*_*ont 50

这是一个完整的完整示例,其中包含比链接问题更详细,更清晰的代码,应提供更好的答案.非常及时,因为我最近完成了移植之前发布的代码,使用适当的ProgId元素,所以这在我的脑海中是新鲜的;)

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

<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="SOFTWARE\MyApp\Capabilities" Name="ApplicationDescription" Value="!(loc.ApplicationDescription)" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities" Name="ApplicationIcon" Value="[APPLICATIONFOLDER]MyApp.exe,0" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities" Name="ApplicationName" Value="!(loc.ApplicationName)" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\DefaultIcon" Value="[APPLICATIONFOLDER]MyApp.exe,1" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\FileAssociations" Name=".xyz" Value="MyApp.Document" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\MIMEAssociations" Name="application/xyz" Value="MyApp.Document" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\shell\Open\command" Value="&quot;[APPLICATIONFOLDER]MyApp.exe&quot; &quot;%1&quot;" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="MyApp" Value="SOFTWARE\MyApp\Capabilities" Type="string" />

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

    <!-- Extend to the "open with" list + Win7 jump menu pinning  -->
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\MyApp.exe\SupportedTypes" Name=".xyz" Value="" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\MyApp.exe\shell\open" Name="FriendlyAppName" Value="!(loc.ApplicationName)" Type="string" />

    <!-- MyApp.Document ProgID -->
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\MyApp.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="SOFTWARE\Classes\SystemFileAssociations\.xyz\shell\edit.MyApp.exe" Value="!(loc.ExplorerMenuEditXYZ)" Type="string" />
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\SystemFileAssociations\.xyz\shell\edit.MyApp.exe\command" Value="&quot;[APPLICATIONFOLDER]MyApp.exe&quot; &quot;%1&quot;" Type="string" />
</Component>
Run Code Online (Sandbox Code Playgroud)

  • 该示例(尤其是 ProgId 部分)看起来很像我的 WiX 代码,它接管已注册的文件扩展名。处理原始问题的技巧是什么,即防止 ProgId/Extension/Verb 元素接管现有扩展?示例:我安装了一个处理 JPG 扩展名的程序。我不想让我的程序成为默认程序。我想要一个广告注册。我想参与“打开方式”。我已经解决了默认程序、注册打开方式等问题,但如何防止强迫自己成为默认程序? (2认同)