473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 3359
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
0
by: Roman Muntyanu | last post by:
Hi all, I wrote add-in that can do different job for files with different extension. When I do right click on the file I see all my custom menuItems in context menu of solution explorer for all...
2
by: Dino M. Buljubasic | last post by:
I have several context menus added to my form. The form is displaying items in listviews connected to the context menus. When I click on an item in a list view, a popup context menu shows allowing...
2
by: Doug Bell | last post by:
Hi, I would like to add a Menu Item to the Explorer Context Menu so that when the User Right Clicks on a File, they are given a choice to launch my application with the selected file passed as a...
0
by: Paul Bromley | last post by:
Can anyone tell me if it is possible to use a contextmenu from my application as a contextmenu for an external application - i.e. suppress the centextmenu of the external application. Altrenativley...
0
by: lushdog | last post by:
Hi, i'm having a little problem with my context menu handler. Basically if i select multiple files and right-click OPEN or EDIT, it uses my context menu to open it. It is because i am missing this...
1
by: Johan | last post by:
I'm trying to send files from the shell context menu to my application. To do this I have added a registry key like this: "hkey_classes_root\*\shell\Default" = "C:\my_program.exe" "%1" Now,...
1
by: natanr123 | last post by:
I want to do something like this. When i right click on selected text in windows i want to add anather option the stantard Copy Cut Paste that will change the selected text to anather string ...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.