如何通过右键单击事件(动词)将多个文件/文件夹路径传递给可执行文件?
相关:
如何向 Windows 中的文件夹和文件上的右键单击事件添加新项目?
我通过将注册表项添加到 HKEY_CLASSES_ROOT\* 来向所有文件添加自定义右键单击动词。 最终结果看起来像这样
HKEY_CLASSES_ROOT*\Shell\TestRightClick\Command
--------默认 = c:\RightClickTest.exe "%1"
问题:选择多个文件时 c:\RightClickTest.exe 会被多次调用次(所选文件的数量)
我需要什么:将多个文件路径传递给一个可执行文件
Related:
How to add new items to right-click event on Folders and Files in Windows?
I added custom right-click verb to all files by adding registry keys to HKEY_CLASSES_ROOT\*.
End result looks like this
HKEY_CLASSES_ROOT*\Shell\TestRightClick\Command
-------Default = c:\RightClickTest.exe "%1"
Problem: when selecting multiple files c:\RightClickTest.exe will be called several times(number of selected files)
What I need: pass-in multiple files paths to one executable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在寻找一种快速而肮脏的解决方法,您可以在“%AppData%\ Microsoft \ Windows \ SendTo”中创建可执行文件的快捷方式现在您可以选择一堆文件,右键单击,选择“发送到”,然后您的应用。
这会将所有选定的文件作为单独的命令行选项传递到应用程序的一个实例...请记住,命令行有 32767 个字符的限制,这将限制您可以使用此方法传递到应用程序的文件数量,并且确保您的程序不会尝试打开它不知道如何处理的文件。从长远来看,Factor Mystic 的方法要好得多。
If you're looking for a quick and dirty workaround, you can create a shortcut to your executable in '%AppData%\Microsoft\Windows\SendTo' Now you can select a bunch of files, right click, select Send To, and your application.
This will pass all the selected files as individual command line options to one instance of your application... keep in mind there is a 32767 character command line limit which will limit the number of files you can pass to your application using this method, and make sure your program wont' try to open files it doesn't know how to deal with. In the long run, Factor Mystic's method is way better.
正如我在上一个问题中所说,您必须在应用程序中对此保持警惕。如果您不使用 shell 扩展,则每个选定的文件都会启动该程序的一个实例。您的一般策略可能是这样的:
%1
) 启动应用程序时,检查应用程序的任何实例是否已在运行。As I stated in the previous question, you're going to have to be intelligent about this inside your application. One instance of the program will be launched per file selected if you're not using a shell extension. Your general strategy could be this:
%1
), check if any instance of the application are already running.