Windows Explorer Right Click Menu Item for my Application

Hello,
i want to put a menu item for my application to the right click menu of windows explorer.
I do not want to do it programmatically but i want to do it with the .NET installer.
Until now i have found that i have to insert into the registry the following keys:
HKEY_CLASSES_ROOT/*/shell/MyApplication/command
and i have to put there a new value of
"[TARGETDIR]MyApplication.exe" "-file=%1"

The problem is that i want to be able to select multiple files and then call my application with parameter all of these files.

Now when i right click with many selected files my application is run for each file sepparately.
I want to run my application only once and with an input parameter of all the files that are selected.

Also until now i cannot add a value to the (Default) key. It only adds a new value to the registry...

Also i want to be able to do the same thing with folders...

Thanks !
LVL 1
alexr123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vidularandunuCommented:
well I don't think this is easy, but here goes.

you can make your program so that only one instance can be run at any given time. when the program is running, and you open a file with it through explorer, the new program instance should check whether another instance of the program is running, and send the parameter to that proces..by means of Inter Process Communication, you could probably use message passing for this. and in the main program, create a thread to look for messages and process the arguments when they are present.

this might help: http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

on the other hand... here's a different approach..
http://en.wikibooks.org/wiki/Windows_Programming/MDI_Programs
0
alexr123Author Commented:
sorry but this was not helpful..
0
vidularandunuCommented:
I'm sorry but this cannot be done purely through the registry. you can also try writing a shell extension. which is apparently how it should be done but it isn't straightforward .net

http://www.theserverside.net/tt/articles/showarticle.tss?id=ShellExtensions
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

alexr123Author Commented:
ok.
can you please provide some code how to detect if an instance of my application is already running and how to send to that process a message ? also provide some code of how to collect the messages.

just this.
0
vidularandunuCommented:
indeed...

here's how you can limit the number of instances...this should be done at the main program

static void Main()
        {
            bool blnFirstInstance;
            using (Mutex objMutex = new Mutex(false, "Local\\" + "AppName", out blnFirstInstance))
            {
                if (!blnFirstInstance)
                {
                    MessageBox.Show("Program is already running", "Single Use Only", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    Application.Exit();
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form1());
                }
            }
           
        }


and as for named pipes...
http://www.switchonthecode.com/tutorials/interprocess-communication-using-named-pipes-in-csharp


I hope this helps..it's not an easy thing to do.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alexr123Author Commented:
Thanks. I finally did it with sending a WM_COPYDATA message to the first application process that does collect it in WndProc of the main window.
But your posts leaded me to the correct direction..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.