• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 929
  • Last Modified:

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 !
0
alexr123
Asked:
alexr123
  • 3
  • 3
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now