如何将我自己的文件关联添加到“打开方式"中上下文菜单? [英] How to add my own file association into the "Open with" context menu?

查看:23
本文介绍了如何将我自己的文件关联添加到“打开方式"中上下文菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比如说,如果我右键单击一个文件,然后转到打开方式"菜单,它会显示一个子菜单,类似于这个:

Say, if I right-click a file and then go to "Open with" menu, it will show a submenu, similar to this one:

如何将我自己的程序添加到打开方式"列表中?

How can I add my own program to that "Open with" list?

附注.请注意,在这种情况下,我不需要创建与特定文件扩展名(用户通常双击打开)的关联.

PS. Note that in this case I do not need to create an association with a particular file extension (that a user normally double-clicks to open.)

PS2.从技术上讲,我需要通过 MSI 安装程序完成此操作(我使用的是 WiX),但如果有人可以建议设置 API 或注册表,我也可以通过自定义操作执行此操作,如果 MSI/WiX 不直接支持它.

PS2. I technically need this done from an MSI installer (I'm using WiX) but if someone can suggest APIs or registry to set up I can do this from a custom action as well, if MSI/WiX doesn't directly support it.

推荐答案

我想我从 thisthis 文章.

I think I found the answer from this and this articles.

比如说,如果我正在制作一个Text Zapper"应用程序并希望将它与打开方式".txt 文件相关联.这是 WiX (MSI) 布局的伪标记.它基本上定义了需要设置的注册表项.(请注意,它没有为应用定义 .txt 扩展默认关联.)

Say, if I was making a "Text Zapper" app and wanted to associate it to "Open With" .txt files. Here's a pseudo-markup for the WiX (MSI) layout. It basically defines the registry keys that need to be set. (Note that it doesn't define the .txt extension default association for the app.)

<?define ProgId = "Text.Zapper.1" ?>
<?define GuiAppExeName = "txtzpr.exe" ?>
<?define ProductThis = "Text Zapper" ?>
<?define AppDescr = "Wonderful Text Zapper Application" ?>


<Component Id='IdTextZapper' Guid='*'>
  <File Id='IdTextZapperExe' Name='$(var.GuiAppExeName)' DiskId='1' Source='$(var.Srctxtzpr)' KeyPath='yes' />

  <!-- Extend the "open with" Windows Explorer function -->
  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\$(var.ProgId)" Value="$(var.ProductThis)" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)" Name="FriendlyAppName" Value="$(var.ProductThis)" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)\shell\open" Name="FriendlyAppName" Value="$(var.ProductThis)" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)\shell\open\command" Value='"[INSTALLDIR]$(var.GuiAppExeName)" "%1"' Type="string" />

  <RegistryValue Root="HKLM" Key="SOFTWARE\My Company\Text Zapper\Capabilities" Name="ApplicationDescription" Value="$(var.AppDescr)" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="$(var.ProductThis)" Value="SOFTWARE\My Company\Text Zapper\Capabilities" Type="string" />

  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.txt\OpenWithProgIDs" Name="$(var.ProgId)" Value="" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.txt\OpenWithList\$(var.GuiAppExeName)" Value="" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)\SupportedTypes" Name=".txt" Value="" Type="string" />
  <RegistryValue Root="HKLM" Key="SOFTWARE\My Company\Text Zapper\Capabilities\FileAssociations" Name=".txt" Value="$(var.ProgId)" Type="string" />

</Component>

这篇关于如何将我自己的文件关联添加到“打开方式"中上下文菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆