473,947 Members | 8,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3403
"Gary" <ga****@yahoo.c omschrieb:
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.c omwrote:
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******** *****@TK2MSFTNG P06.phx.gbl...
"Gary" <ga****@yahoo.c omschrieb:
> 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
3088
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 up, the window does not closes until I click on the window. Below is the code. Hopefully, you can help me out.
0
277
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 kind of files . But I want to see only menuItem that specific for the file selected. Ok, after I click on one of the menu Item action performs and when I do right click next time I see only menu Item specific for file selected e.g. it works as I...
2
1653
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 me to chese between editing or deleting the item from the list view. That works fine. However, in addition to calling the context menu on Click, I can call it also by RightClick which causes application to either freeze, crash, call Delete...
2
1835
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 command line argument. Can someone point me to some information on how to set that up? Hopefully as part of the installation? Thanks
0
863
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 is their anyway that I can mimmick this?? Presently using VB2003. Many thanks Paul Bromley
0
3269
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 line of code of C++ in my C# code. ------------------------- // If lpVerb really points to a string, ignore this function call and bail out. if ( 0 != HIWORD( pInfo->lpVerb )) return E_INVALIDARG;
1
2954
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, this works for one file but if I try to send multiple files, then multiple instances of my application are opened. Does anyone know how I can send a list of files to my application by the shell context meny?
1
1407
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 Please help me natanr123@vfemail.net
4
4222
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 choose, I want to be able to select several files, right click my mouse and launch an application which will act on the selected files. However, I don't even know where to start and have a number of questions!
0
9983
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11168
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10693
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9889
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6117
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4947
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.