Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
'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.
Posted

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900