与此相关:How to register file types/extensions with a WiX installer?但不重复。
我需要处理现有的文件类型(.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>
这里有很多方法可以失败(就像Photo Mechanics一样,在安装了这个软件后,HKCR的图像文件类型真的很乱)。
如何使用WiX正确执行此操作?
答案 0 :(得分: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=""[APPLICATIONFOLDER]MyApp.exe" "%1"" 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=""%1"" />
<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=""[APPLICATIONFOLDER]MyApp.exe" "%1"" Type="string" />
</Component>