在Windows上下文菜单中复制为路径

时间:2010-05-25 05:38:25

标签: windows windows-xp regedit

我正在尝试在Windows上下文菜单中实现“复制为路径”选项,该选项将当前文件或文件夹路径复制到剪贴板 而不是为此安装软件,我想实现它自己。有什么建议吗?

3 个答案:

答案 0 :(得分:1)

您可以通过摆弄File Types对话框或使用注册表来添加指向上下文菜单的链接。在注册表中,路径为HKEY_CLASSES_ROOT\*\shell。在名为“Copy as path”的名称下添加一个密钥,在名为“command”的密钥下添加一个密钥。将命令的默认字符串值更改为“c:\ your-program.exe%1”,当用户选择“复制为路径”时,它将以该路径作为参数运行可执行文件。现在你的可执行文件只需要将传递给它的路径写入剪贴板

答案 1 :(得分:1)

您需要编写自己的 shell命名空间扩展。关于如何使用C#is available here进行操作的示例。关于如何在Web上用C ++实现这一点的例子很多。

MSDN上提供了有关该主题的官方文档。有关此主题的特定文章是Creating Context Menu Handlers

答案 2 :(得分:0)

Windows Registry Editor Version 5.00

;Scripted by Jeff Hollis
;(https://stackoverflow.com/users/10572786/slyfox1186)
;To edit this script manually using hex(2) you must utilize OTConvertIt.exe
;(http://www.geekstogo.com/forum/files/file/404-otconvertit)
;or equivalent to decipher hex(2) into "Windows Registry Editor Version 5.00" aka ASCII or vice versa.
;REG_EXPAND_SZ is the only type of registry entry that will work entirely for this
;particular type of context menu item.

;%%%%%%%%%%%%%%%% COPY PATH NO QUOTES %%%%%%%%%%%%%%%%

;hex(2) below deciphers as:
;cmd /c <nul (set/p var="%1")|clip
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path No Quotes]
"Icon"="imageres.dll,-5302"
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path No Quotes\command]
@=hex(2):63,00,6D,00,64,00,20,00,2F,00,63,00,20,00,\
  3C,00,6E,00,75,00,6C,00,20,00,28,00,73,00,65,00,74,00,2F,00,70,00,20,00,\
  76,00,61,00,72,00,3D,00,22,00,25,00,31,00,22,00,29,00,7C,00,63,00,6C,00,\
  69,00,70,00,00,00

;hex(2) below deciphers as:
;cmd /c <nul (set/p var="%V")| clip
[HKEY_CLASSES_ROOT\Directory\Background\shell\Copy Path No Quotes]
"Icon"="imageres.dll,-5302"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Copy Path No Quotes\command]
@=hex(2):63,00,6D,00,64,00,20,00,2F,00,63,00,20,00,\
  3C,00,6E,00,75,00,6C,00,20,00,28,00,73,00,65,00,74,00,2F,00,70,00,20,00,\
  76,00,61,00,72,00,3D,00,22,00,25,00,56,00,22,00,29,00,7C,00,20,00,63,00,\
  6C,00,69,00,70,00,00,00

;%%%%%%%%%%%%%%%% COPY PATH WITH QUOTES %%%%%%%%%%%%%%%%

;hex(2) below deciphers as:
;cmd /c <nul echo|set/p var=""%1""|clip
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path With Quotes]
"Icon"="imageres.dll,-5302"
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path With Quotes\command]
@=hex(2):63,00,6D,00,64,00,20,00,2F,00,63,00,20,00,\
  3C,00,6E,00,75,00,6C,00,20,00,65,00,63,00,68,00,6F,00,7C,00,73,00,65,00,\
  74,00,2F,00,70,00,20,00,76,00,61,00,72,00,3D,00,22,00,22,00,25,00,31,00,\
  22,00,22,00,7C,00,63,00,6C,00,69,00,70,00,00,00

;hex(2) below deciphers as:
;cmd /c <nul echo|set/p var=""%V""|clip
[HKEY_CLASSES_ROOT\Directory\Background\shell\Copy Path With Quotes]
"Icon"="imageres.dll,-5302"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Copy Path With Quotes\command]
@=hex(2):63,00,6D,00,64,00,20,00,2F,00,63,00,20,00,\
  3C,00,6E,00,75,00,6C,00,20,00,65,00,63,00,68,00,6F,00,7C,00,73,00,65,00,\
  74,00,2F,00,70,00,20,00,76,00,61,00,72,00,3D,00,22,00,22,00,25,00,56,00,\
  22,00,22,00,7C,00,63,00,6C,00,69,00,70,00,00,00