Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Creating a context menu in Explorer which sends multiple file arguments to an external application

Hello experts,

I've created an entry in the registry using a program written in C# which adds another program I've written, I will call it argument_acceptor.exe, to the context menu of Windows Explorer, and I need this program to accept all of the file arguments passed to it.

The path which I used to create a context menu item for the application is HKEY_CLASSES_ROOT/*/shell/Application Name/Command. Also I made a duplication at HKEY_CLASSES_ROOT/Folder/shell/Application Name/Command to create a context menu for directories.

The default value of these keys are set to

argument_acceptor.exe %1

However, if I select more than one file/folder and click on the context menu item this doesn't send all of the arguments to it. I've also tried, with and without quotes:

argument_acceptor.exe "%L"
argument_acceptor.exe "%l"

but I only get one argument in the external argument_acceptor.exe program for all of these cases, or sometimes the argument_acceptor.exe program crashes when I try to send multiple files.

Does anyone know what to append after the application path or did I just make the argument_acceptor.exe program incorrectly?

The argument_acceptor.exe program is pretty straigtforward, just:
        [STAThread]
        static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                MessageBox.Show(arg);
            }
        }

Thanks,
Marty
0
Marty83902
Asked:
Marty83902
  • 2
1 Solution
 
jkrCommented:
If you want that functionality, you'll need to create a ContextMenuHandler inside a COM DLL (see http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/extensionhandlers/contextmenuhandlers.asp "Creating Context Menu Handlers"). You'll then receive all selections in your 'InvokeCommand()' implementation, which you can use to build a complete command line to call your application.
0
 
Marty83902Author Commented:
Thanks. Too bad it can't be done by just setting the registry key to a certain value, but it looks like I might have to pour through all of the extra stuff for setting up this COM DLL. Does anyone know of a tutorial of how to make the COM DLL but doesn't give all of the extra functionality, and just explains how to pass the file and folder arguments? (If not, I'll accept jkr's comment.)
0
 
jkrCommented:
Sorry for being late here, but if you can read C++, check out the sample code that you can find on that site by clicking on the "Show Example" links (they used to have the whole code available for download via a single link earlier, but for whatever reason...)
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

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