Board index » Visual Studio » Call up application from context menu (on multiple selected files)

Call up application from context menu (on multiple selected files)

Visual Studio346
Hi all,



I am writing an application which will intake arguments of filenames for

processing:



e.g. MyApp.exe "C:\abc.txt" "C:\def.doc"

- then, MyApp will process the 2 files by parsing the 2 arguments

- the retrieval method used is My.Application.CommandLineArgs



It works as expected until I work with context menu:

I added a few entries in registry, such that on any file, the windows

context menu (right-click menu) will have a new entry "Open with MyApp",

with this entry is having the follwing "command" in registry:



'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.



Would anyone advice how to do this please?

Please let me know if you need further clarification on my problem.



Thanks in advance!


-
 

Re:Call up application from context menu (on multiple selected files)

"Gary" <garycc@yahoo.com>schrieb:

Quote
I added a few entries in registry, such that on any file, the windows

context menu (right-click menu) will have a new entry "Open with MyApp",

with this entry is having the follwing "command" in registry:



'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.



You could add a check to your application which checks if the application is

already running. If this is the case and a file name has been specified,

you could transfer the file name to the existing instance of your

application (via sockets, remoting, ...).



--

M S Herfried K. Wagner

M V P <URL:dotnet.mvps.org/>">dotnet.mvps.org/>

V B <URL:dotnet.mvps.org/dotnet/faqs/>">dotnet.mvps.org/dotnet/faqs/>



-

Re:Call up application from context menu (on multiple selected files)

On Jan 15, 10:29 am, "Gary" <gar...@yahoo.com>wrote:

Quote
Hi all,



I am writing an application which will intake arguments of filenames for

processing:



e.g. MyApp.exe "C:\abc.txt" "C:\def.doc"

- then, MyApp will process the 2 files by parsing the 2 arguments

- the retrieval method used is My.Application.CommandLineArgs



It works as expected until I work with context menu:

I added a few entries in registry, such that on any file, the windows

context menu (right-click menu) will have a new entry "Open with MyApp",

with this entry is having the follwing "command" in registry:



'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.



Would anyone advice how to do this please?

Please let me know if you need further clarification on my problem.



Thanks in advance!



I have searched the same solution with no help. Stuck on %1 or L

parameter because of the purpose of adding multiple files's paths into

my project's listbox.



http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/f057993c5a30fdcc?hl" rel="nofollow" target="_blank">groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/f057993c5a30fdcc=en



My purpose is that, when i select multiple files, i cannot "open with"

my app, only one file is opened. Also funny, if i put my app's

shortcut on "send to" folder i can add multiple files into my app with

no problem.



I hope a solution will be welcomed.

-

Re:Call up application from context menu (on multiple selected files)

Hi Herfried,



Thanks for your reply.



Would you please also suggest some directions on

- how to check for other instances and do the transfer?

- how to make sure that ALL instances have finished the transfer (so as

to ensure all selected files are processed)?



Thanks very much again!





"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at>wrote in message

Quote
"Gary" <garycc@yahoo.com>schrieb:

>I added a few entries in registry, such that on any file, the windows

>context menu (right-click menu) will have a new entry "Open with MyApp",

>with this entry is having the follwing "command" in registry:

>

>'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.



You could add a check to your application which checks if the application

is already running. If this is the case and a file name has been

specified, you could transfer the file name to the existing instance of

your application (via sockets, remoting, ...).



--

M S Herfried K. Wagner

M V P <URL:dotnet.mvps.org/>">dotnet.mvps.org/>

V B <URL:dotnet.mvps.org/dotnet/faqs/>">dotnet.mvps.org/dotnet/faqs/>



-