复制为 Windows 上下文菜单中的路径
我正在尝试在 Windows 上下文菜单中实现“复制为路径”选项,它将当前文件或文件夹路径复制到剪贴板 我不想为此安装软件,而是想自己实现它。有什么建议吗?
I'm trying to implement "Copy as path" option in windows context menu ,which copies current file or folder path to clip board
instead of installing a software for this , i would like to implement it my self. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
.reg
扩展名保存此文件,并以管理员身份运行该文件,以将“复制为路径”添加到 Windows 上下文菜单。Save this with a
.reg
extension and run the file as an administrator to add Copy as Path to the Windows context menu.您可以通过摆弄“文件类型”对话框或使用注册表来添加到上下文菜单的链接。在注册表中,路径为
HKEY_CLASSES_ROOT\*\shell
。在名为“Copy as path”的键下添加一个键,在名为“command”的键下添加一个键。将命令的默认字符串值更改为“c:\your-program.exe %1”,当用户选择“复制为路径”时,它将使用该路径作为参数运行可执行文件。现在您的可执行文件只需将传递给它的路径写入剪贴板You can add a link to the context menu by fiddling with the
File Types
dialog, or using the registry. In the registry, the path isHKEY_CLASSES_ROOT\*\shell
. Add a key under that named "Copy as path", and a key under that named "command". Change command's default string value to "c:\your-program.exe %1", and when the user selects "Copy as path" it will run your executable with that path as the argument. Now your executable just needs to write the path passed in to it to the clipboard您需要编写自己的shell 命名空间扩展。有关如何使用 C# 执行此操作的示例可在此处获取 。 Web 上也有很多关于如何在 C++ 中执行此操作的示例。
有关该主题的官方文档可在 MSDN 上找到。有关此主题的具体文章是创建上下文菜单处理程序。
You will need to write your own shell namespace extension. A sample on how to do that using C# is available here. There is many examples on how to do that in C++ on web too.
The official documentation on the topic is available at MSDN. A specific article on this topic is Creating Context Menu Handlers.