如何在Windows上下文菜单中为具有特定扩展名的文件添加条目? [英] How to add an entry in the Windows context menu for files with a specific extension?

查看:86
本文介绍了如何在Windows上下文菜单中为具有特定扩展名的文件添加条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有关如何自定义外壳上下文菜单的问题很多,但是我尝试过的仍然无法正常工作,因此我添加了一个新问题。

I know that many questions are asked about how customizing the shell context menu, but what I've tried yet doesn't work so I'm adding a new question.

在右键单击扩展名为 .log的文件时,我想在上下文菜单中添加条目使用日志查看器打开,以不更改与.log文件(记事本)关联的默认应用程序,但允许用户选择一个自定义应用程序来打开它们。

I'd like to add an entry "Open with Log Viewer" in the context menu when right-clicking on files with ".log" extension, to not change the default application associated with .log files (notepad) but allow the user to choose a custom application to open them.

为此,我打开了注册表项 HKEY_CLASSES_ROOT\.log ,并添加了一些具有正确值的键 shell\OpenWithLogViewer\command ,但是当我右键单击带有.log的文件时,不会显示该条目

To do this, I opened the registry key HKEY_CLASSES_ROOT\.log, and added some keys shell\OpenWithLogViewer\command with the correct values, but the entry is not displayed when I right-click on a file with .log extension.

您知道如何解决此问题吗?

Would you know how to fix this?

密钥 HKEY_CLASSES_ROOT\ log.log 的默认值为 txtfile ,并包含一个名为 PersistentHandler 的子项。

The key HKEY_CLASSES_ROOT\.log has for default value txtfile, and contains a subkey called PersistentHandler. Can this subkey be the origin of the problem?

推荐答案

如果要为文件扩展名添加条目,则不需要拥有,并且您永远不想成为默认操作,则可以使用 SystemFileAssociations 键:

If you want to add a entry for a file extension you don't "own" and you never want to be the default action then you can use the SystemFileAssociations key:

[HKEY_CLASSES_ROOT\SystemFileAssociations\.log\shell\mycommand]
@="My Command"

[HKEY_CLASSES_ROOT\SystemFileAssociations\.log\shell\mycommand\command]
@="\"c:\\path\\myapp.exe\" \"%1\""




要主动处理更改默认程序的后果,可以使用HKEY_CLASSES_ROOT\SystemFileAssociations来注册动词和其他关联信息。由于它们在关联数组中ProgID之后的位置,因此这些注册的优先级较低。这些SystemFileAssociations注册即使在用户更改默认程序时也很稳定,并提供了一个位置来注册辅助动词,该动词对于特定文件类型始终可用。

To deal proactively with the consequences of a change to default programs, you can use HKEY_CLASSES_ROOT\SystemFileAssociations to register verbs and other association information. Due to their location after the ProgID in the association array, these registrations are lower priority. These SystemFileAssociationsregistrations are stable even when users change the default programs, and provide a location to register secondary verbs that will always be available for a particular file type.

此键在Windows XP和更高版本上可用...

This key is available on Windows XP and higher...

这篇关于如何在Windows上下文菜单中为具有特定扩展名的文件添加条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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