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

Installation 如何使用WiX安装程序将应用程序与现有文件类型关联?,installation,wix,registry,windows-installer,file-type,Installation,Wix,Registry,Windows Installer,File Type,与此相关:但不是重复 我需要处理现有的文件类型(.jpg文件) 我不希望我的应用程序成为.jpg的默认处理程序。我只想用我的应用程序链接扩展“打开方式”菜单 我在注册表中看到HKCR\.jpg\OpenWithList\和HKCR\.jpg\OpenWithProgIds\,但我不确定是否要写入这些,以及如何使用WiX正确执行。我应该用这样的东西吗 <ProgId Id='??what here?' Description='Jpeg handled by my App'> &l

与此相关:但不是重复

我需要处理现有的文件类型(.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>

这里有很多失败的方法(就像光力学一样,在我安装了这个软件之后,HKCR的图像文件类型真的是一团糟)


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

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

关于“what here”,你可以随意使用:)



萨沙对链接问题的回答不是提供了这一点吗?特别是,看看五个注册表值,包括OpenWith。。。钥匙。(或者可能有一种更简洁的方法在WiX中指定这一点。)我对Sasha遗漏的正确方法很感兴趣-我想了解哪些值用于描述/内容类型等,如?what here?我的问题是。我还想了解哪些值是必需的,哪些值不是。链接的答案似乎包含了一些可能不需要的内容,以简单地提供一个文件处理程序。啊。。。我不久前写下了这个答案。将尽快发布清理代码。很酷的例子!您从哪里收集到所有这些注册表项所需的信息?你有MSDN文章的链接吗?这个例子,特别是在ProgId部分,看起来很像我的WiX代码,它接管了已经注册的文件扩展名。处理原始问题的诀窍是什么,即防止ProgId/Extension/Verb元素接管现有的扩展?示例:我安装了一个处理JPG扩展的程序。我不想使我的程序成为默认程序。我想要一份注册广告。我想参加“开放与”。我有默认程序,注册为Open With等。所有这些都解决了,但是如何防止强迫自己成为默认程序呢?对于Windows 8,这个问题有点消失了(最后!)对于较旧的操作系统,在不接管默认程序的情况下进行广告注册将面临问题。您需要在一个单独的组件中使用未公布的注册表项,如果它们的关联已经存在,则不会安装该注册表项。我不再使用Windows Installer,但基本上只是放弃了尝试干净地处理旧系统,因为底层的Windows逻辑似乎被破坏了。我知道这是一个旧答案,但使用这段代码我似乎遇到了区分大小写的问题。e、 它适用于TXT,但不适用于TXT。这种解决方案是否仍然存在区分大小写的问题?
<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>