在Windows中为特定文件扩展名添加上下文菜单项 [英] Adding a context menu item in Windows for a specific file extension

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

问题描述

我正在尝试将上下文菜单项添加到DLL文件。原因是我编写了一个应用程序,该应用程序可将托管的DLL文件撤回并将其部署到GAC。该应用程序很好,但是现在我希望能够右键单击一个DLL,然后单击复制到GAC。



我尝试按照以下问题的说明进行操作:



任何指导将不胜感激。

实现此目的的一般步骤如下:


  1. 启动 regedit

  2. 标识扩展的ProgID-转到 HKCR\.yourexte nsion 并记下默认值(在您的情况下为 dllfile

  3. 导航至 HKCU\软件\类(适用于用户)或 HKLM\软件\类(适用于所有用户)

  4. 查找匹配的密钥(在您的情况下为 dllfile )-如果不存在,则创建它

  5. 确保它有一个名为 shell
  6. 的子项
  7. shell中添加一个子项命名为所需的命令(请参见下图)

  8. 在新密钥中添加一个名为 command

  9. (默认)值修改为要执行的命令。 %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:

  1. Fire up regedit
  2. Identify the ProgID for your extension - go to HKCR\.yourextension and take note of the default value (in your case, dllfile)
  3. Navigate to HKCU\Software\Classes (for user) or HKLM\Software\Classes (for all users)
  4. Look for a matching key (in your case dllfile) - if it's not there, create it
  5. Ensure it has a sub-key called shell
  6. Add a sub-key to shell named as the command you want (refer to image below)
  7. Add a sub-key to your new key called command
  8. 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 than HKCU - due to how inheritance works, I do believe adding it to HKLM 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屋!

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