与如何使用WiX安装程序将应用程序与现有文件类型关联有关?和如何使用WiX安装程序注册文件类型/扩展名?。
如果安装是按用户进行的,如何将应用程序与现有文件类型相关联?
不允许使用HKLM密钥
我相信
这与每台机器的情况没有什么不同。对于向下标记(按用户安装),我将其放在安装应用程序可执行文件的组件中:
<!-- associate .md file extension with downmarker -->
<ProgId Id="DownMarker" Icon="downmarker.exe"
Description="Markdown Document">
<Extension Id="md" >
<Verb Id="open" Argument=""%1""
TargetFile="downmarker.exe" />
</Extension>
</ProgId>
或者您可以查看完整的 wxs 文件。
我们开始了..这应该适用于每用户应用程序,并提供您正在寻找的大部分好东西,除了启动>运行,它仅适用于每台机器。
<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="HKCU" Key="SOFTWAREMyAppCapabilities" Name="ApplicationDescription" Value="!(loc.ApplicationDescription)" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWAREMyAppCapabilities" Name="ApplicationIcon" Value="[APPLICATIONFOLDER]MyApp.exe,0" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWAREMyAppCapabilities" Name="ApplicationName" Value="!(loc.ApplicationName)" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWAREMyAppCapabilitiesDefaultIcon" Value="[APPLICATIONFOLDER]MyApp.exe,1" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWAREMyAppCapabilitiesFileAssociations" Name=".xyz" Value="MyApp.Document" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWAREMyAppCapabilitiesMIMEAssociations" Name="application/xyz" Value="MyApp.Document" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWAREMyAppCapabilitiesshellOpencommand" Value=""[APPLICATIONFOLDER]MyApp.exe" "%1"" Type="string" />
<RegistryValue Root="HKCU" Key="SOFTWARERegisteredApplications" Name="MyApp" Value="SOFTWAREMyAppCapabilities" Type="string" />
<!-- Extend to the "open with" list + Win7 jump menu pinning -->
<RegistryValue Root="HKCR" Key="ApplicationsMyApp.exeSupportedTypes" Name=".xyz" Value="" Type="string" />
<RegistryValue Root="HKCR" Key="ApplicationsMyApp.exeshellopen" Name="FriendlyAppName" Value="!(loc.ApplicationName)" Type="string" />
<!-- MyApp.Document ProgID -->
<RegistryValue Root="HKCR" Key="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="HKCR" Key="SystemFileAssociations.xyzshelledit.MyApp.exe" Value="!(loc.ExplorerMenuEditXYZ)" Type="string" />
<RegistryValue Root="HKCR" Key="SystemFileAssociations.xyzshelledit.MyApp.execommand" Value=""[APPLICATIONFOLDER]MyApp.exe" "%1"" Type="string" />
</Component>