从上下文菜单调用应用程序(在多个选定文件上) [英] Call up application from context menu (on multiple selected files)

查看:69
本文介绍了从上下文菜单调用应用程序(在多个选定文件上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'MyApp.exe%1'



这适用于单个文件,但当我选择多个文件并执行

使用MyApp打开,发生的事情是每个选定的文件将触发1 MyApp的启动,其中MyApp的参数只包含1

所选文件文件。

相反,我想让行为只有1个单独的MyApp将被触发,并且所选文件的文件名列表将是它的参数。

解决方案

在这个问题中,您将混合两个不同的方面:命令行参数和单实例应用程序。



有不同的方法可以防止多个应用程序实例运行(第二个实例会在短时间内启动,检测第一个实例并立即终止)但我开发了一个非常紧凑,简单和健壮的机制,其中相同的技术用于检测先前的inst ance并在命令行上发送信息。请查看我过去的答案:

http://www.codeproject.com/Answers/ 556737 / Enterplusmultiplepluscommandsplustoplusonlyplusone#answer1 [ ^ ],

http://www.codeproject.com/Answers/593594/ CustomplusWindowsplusright-clickpluscommandpluslau#answer1 [ ^ ]。



关于命令行的处理,我推荐自己的库,它非常易于使用且足够灵活;我在我的CodeProject文章中解释它:基于枚举的命令行实用程序 [< a href =http://www.codeproject.com/Articles/144349/Enumeration-based-Command-Line-Utilitytarget =_ blanktitle =New Window> ^ ]。



在本文中,我还推荐了另一个更复杂的解决方案,该解决方案也在CodeProject中发布。



< DD> -SA

'MyApp.exe "%1"'

This works with single file, but when I select multiple files and do
"Open with MyApp", what happened is that each selected file will trigger the
startup of 1 MyApp, with argument to MyApp as only containing filename of 1
of the selected files.
Instead, I want to have the behavior as only 1 single MyApp will be
triggerred, and the list of filename of selected files will be its argument.

解决方案

In this question, you are mixing two different aspects: command line parameters, and single-instance application.

There are different methods of preventing multiple application instances from running (second instance is started for short time, detects the first instance and terminates itself immediately), but I developed a very compact, simple and robust mechanism where the same technique is used for detection of the previous instance and sending information on the command line. Please see my past answers:
http://www.codeproject.com/Answers/556737/Enterplusmultiplepluscommandsplustoplusonlyplusone#answer1[^],
http://www.codeproject.com/Answers/593594/CustomplusWindowsplusright-clickpluscommandpluslau#answer1[^].

As to the processing of a command line, I would recommend my own library which is very easy to use and flexible enough; I explain it in my CodeProject article: Enumeration-based Command Line Utility[^].

In this article, I also recommend another, more complex solution, which is also published in CodeProject.

—SA


这篇关于从上下文菜单调用应用程序(在多个选定文件上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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