?
Solved

How to pass multiple folders into my C# application's command line?

Posted on 2009-07-12
1
Medium Priority
?
380 Views
Last Modified: 2012-05-07
Hi,

I have an application that processes a folder's contents by the user going into Windows Explorer and right-clicking on a folder, and choosing to "Convert images for iPhone".

The "Convert images for iPhone" popup menu verb was added to my environment by using the shown registry data to my registry.

My C# Windows Forms application processes figures out which folder to process by inspecting the results of "Environment.GetCommandLineArgs()".

Currently, if I select multiple folders and choose my verb in Windows Explorer, it just opens up a new instance of my application for each folder. So, selecting 3 folders runs 3 instances of my application at the same time.

What I would like to do now, is be able to select multiple folders within Windows Explorer, and process that list of folders within a SINGLE instance of my application.

How can I achieve this?

Perhaps I can pass them all in a single command-line, as %1 %2 %3, etc. If so, how do I set this up?

Or, is there some way to tell Windows to only run one instance of my application, and pass the folder names in a way other than the command-line arguments? How would I do this?

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\Folder\shell\ConvertImagesForIPhone]
@="Convert images for iPhone"
 
[HKEY_CLASSES_ROOT\Folder\shell\ConvertImagesForIPhone\command]
@="\"C:\\dev\\mainline\\vs\\AutoRotatePhotos\\AutoRotatePhotos\\bin\\Debug\\AutoRotatePhotos.exe\" \"%1\""

Open in new window

0
Comment
Question by:JimR123b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 1000 total points
ID: 24834390
You can use %* in the command to get all dropped filed instead of only the first. Try if that will make explorer send all the folders to the same instance.
[HKEY_CLASSES_ROOT\Folder\shell\ConvertImagesForIPhone\command]
@="\"C:\\dev\\mainline\\vs\\AutoRotatePhotos\\AutoRotatePhotos\\bin\\Debug\\AutoRotatePhotos.exe\" \"%*\""

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question