繁体   English   中英

如何将自己的文件关联添加到“打开方式”上下文菜单中?

[英]How to add my own file association into the “Open with” context menu?

说,如果我右键单击一个文件,然后转到“打开方式”菜单,它将显示一个子菜单,类似于此菜单:

在此处输入图片说明

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

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

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

我想我从本文本文中找到了答案。

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

<?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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM