How to pass in multiple file/folder paths via a right-click event (verb) to an executable?

可紊 提交于 2019-11-27 04:53:35

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. When the application is launched with a file parameter (%1), check if any instance of the application are already running.
  2. If another instance is running, open some sort of Inter-Process Communication (IPC) channel to that application.
  3. Communicate the file parameter of this instance to the main instance.
  4. Write logic in the main program to address receiving this information as it's running.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!