在Windows中为特定文件扩展名添加上下文菜单项 [英] Adding a context menu item in Windows for a specific file extension
问题描述
我正在尝试将上下文菜单项添加到DLL文件。原因是我编写了一个应用程序,该应用程序可将托管的DLL文件撤回并将其部署到GAC。该应用程序很好,但是现在我希望能够右键单击一个DLL,然后单击复制到GAC。
我尝试按照以下问题的说明进行操作:
任何指导将不胜感激。
实现此目的的一般步骤如下:
- 启动
regedit
- 标识扩展的ProgID-转到
HKCR\.yourexte nsion
并记下默认值(在您的情况下为dllfile
) - 导航至
HKCU\软件\类
(适用于用户)或HKLM\软件\类
(适用于所有用户) - 查找匹配的密钥(在您的情况下为
dllfile
)-如果不存在,则创建它 - 确保它有一个名为
shell
的子项 - 向
shell中添加一个子项
命名为所需的命令(请参见下图) - 在新密钥中添加一个名为
command $ c $的子密钥c>
- 将
(默认)
值修改为要执行的命令。%1
将为您提供上下文中文件的路径(请记住将其包装在
您似乎已经完成了上述所有操作,所以您可能做错了,因为这是我的结果经过快速的健全性测试后:
所以,这里我可以想到的一些事情会使它的行为不直观:
- 您要将其添加到
HKLM
而不是HKCU
-由于继承的原理,我相信将其添加到HKLM
将需要重新启动,或最多只能执行shell重新启动 - 您已将其添加到
HKCU
,但您的dll需要提升权限访问权限 - 您的某处存在一些愚蠢的语法错误;)
该示例我用来测试的命令是一个很好的老无聊的 C:\Windows\notepad.exe%1
I am trying to add a context menu item to a DLL file. The reason is that I have written an application which retracts and deployed a managed DLL file to the GAC. The application is all good, but now I want the ability to right-click a DLL and just click "copy to GAC".
I've tried to follow instructions as per this question: How add context menu item to Windows Explorer for folders but to no avail. When I right click a DLL, nothing new is appearing.
I've also tried the following: https://winaero.com/blog/add-register-dll-context-menu-commands-for-dll-files-in-windows-10/#comment-22928 - ran the reg file but no result as well.
Maybe there's a hardcoded restriction on DLL files for such actions?
Here's my current registry setup:
Any guidance would be appreciated.
The general steps to achieve this are as follows:
- Fire up
regedit
- Identify the ProgID for your extension - go to
HKCR\.yourextension
and take note of the default value (in your case,dllfile
) - Navigate to
HKCU\Software\Classes
(for user) orHKLM\Software\Classes
(for all users) - Look for a matching key (in your case
dllfile
) - if it's not there, create it - Ensure it has a sub-key called
shell
- Add a sub-key to
shell
named as the command you want (refer to image below) - Add a sub-key to your new key called
command
- Modify the
(Default)
value to be the command you want to execute.%1
will give you the path of the file in context (remember to wrap it in"
due to potential white-space in the path)
You seem to have done all the above, so you may be doing something wrong, as this is my result after a quick sanity test:
So, here are a few things I can think of that would make it behave non-intuitively:
- You're adding this to
HKLM
rather thanHKCU
- due to how inheritance works, I do believe adding it toHKLM
would require a restart, or at best, a shell restart - You've added this to
HKCU
but your dll requires elevated permissions to access - You have some silly syntax error somewhere ;)
The sample command I used to test this was a good old boring "C:\Windows\notepad.exe" "%1"
这篇关于在Windows中为特定文件扩展名添加上下文菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!