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
Marty83902Asked:
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.

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

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.