简体   繁体   English

Windows 8特定的文件类型上下文菜单关联

[英]Windows 8 specific file type context menu association

There is a need to add item to particular file type's context menu. 需要将项目添加到特定文件类型的上下文菜单。 In Windows 7 and previous versions that's done by adding 在Windows 7和以前的版本中,通过添加

HKEY_CLASSES_ROOT\<extension>\shell\<commandname>\command

key with value of 值的键

@="<path_to_app> \"%1\""

to registry. 注册。 In Windows 8 that doesn't work. 在Windows 8中不起作用。 Even after deleting PersistentHandler key of respective type : 即使删除了相应类型的PersistentHandler密钥后: 注册表截图

What's interesting, if shell/command keys are written in HKEY_CLASSES_ROOT\\*\\ section, context menu item appears in menu for all files as expected, but that's a huge overhead in case what I need is add my application to only 2-3 filetypes without breaking any existing associations. 有趣的是,如果将外壳/命令键写在HKEY_CLASSES_ROOT\\*\\部分中,则上下文菜单项将按预期显示在所有文件的菜单中,但是如果我需要将我的应用程序仅添加到2-3个文件类型而不添加的话,这将是一个巨大的开销打破任何现有的关联。 I'm using Microsoft.Win32.Registry.ClassesRoot in C# to implement this logic, but the problem is definitely not in code because a) it works in Windows 7 b) manual editing with administrator previledges in Windows 8 doesn't add needed association. 我在C#中使用Microsoft.Win32.Registry.ClassesRoot来实现此逻辑,但是问题绝对不在代码中,因为a)在Windows 7中有效b)在Windows 8中使用管理员权限手动编辑不会添加所需的关联。

You must have noticed that there wasn't a "shell" key originally there, even though .avi files certainly have an Open context menu item. 您必须已经注意到,即使.avi文件确实具有“打开”上下文菜单项,该命令最初也没有“ shell”键。 There's an extra level of indirection, note the default value of the .avi key. 还有一个间接级别,请注意.avi键的默认值。 That's the ProgId associated with the .avi filename extension. 那就是与.avi文件扩展名关联的ProgId。

Follow that to the WMP11.AssocFile.AVI key to find the shell commands, add your command there. 将其跟随到WMP11.AssocFile.AVI项以找到shell命令,然后在其中添加命令。

"HKEY_CLASSES_ROOT\\SystemFileAssociations\\video" is "real" subtree for .avi files in systems with non-WMP default media player. “ HKEY_CLASSES_ROOT \\ SystemFileAssociations \\ video”是具有非WMP默认媒体播放器的系统中.avi文件的“真实”子树。 .mkv file type that i was interested in also creates another subtree - "mkv_auto_file". 我感兴趣的.mkv文件类型还创建了另一个子树-“ mkv_auto_file”。 Don't know why it's done and where it's documented, but my problem was solved. 不知道为什么要这样做以及在哪里记录,但是我的问题解决了。 Thanks Hans for guiding. 感谢汉斯的指导。

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

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