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

G

Gary

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!
 
H

Herfried K. Wagner [MVP]

Gary said:
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, ...).
 
K

kimiraikkonen

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/micr...b/browse_thread/thread/f057993c5a30fdcc?hl=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.
 
G

Gary

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top