469,954 Members | 1,882 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

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

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!

Jan 15 '08 #1
3 3210
"Gary" <ga****@yahoo.comschrieb:
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:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 15 '08 #2
On Jan 15, 10:29 am, "Gary" <gar...@yahoo.comwrote:
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/micro...5a30fdcc?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.
Jan 15 '08 #3
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]" <hi***************@gmx.atwrote in message
news:u2*************@TK2MSFTNGP06.phx.gbl...
"Gary" <ga****@yahoo.comschrieb:
> 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:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Jan 16 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mohit Gupta | last post: by
reply views Thread by Roman Muntyanu | last post: by
2 posts views Thread by Dino M. Buljubasic | last post: by
2 posts views Thread by Doug Bell | last post: by
reply views Thread by lushdog | last post: by
1 post views Thread by Johan | last post: by
1 post views Thread by natanr123 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.