gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:30:44 33 4
gpt4 key购买 nike

相关: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 正确执行此操作?

最佳答案

这是一个完整的示例,比链接的问题有更多细节和更清晰的代码,应该提供更好的答案。非常及时,因为我最近完成了之前发布的代码的移植,以使用正确的 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>

关于installation - 如何使用 WiX 安装程序将应用程序与现有文件类型关联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2772452/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com