I am working on a program that can read, write, and export files, these functions all work fine and are almost perfected. What I would like to do now is to be able to choose a file and tell it to "Open With" (In the Right-Click Context Menu on Windows XP) and have my application be able to handle the file given. I have no idea on where to start or where to look so I thought I'd ask here. Thanks.

Edited by apease11: n/a

8 Years
Discussion Span
Last Post by sknake

you can add commands in the shell using the registry
simply open up the HKEY_CLASSES_ROOT keyset to access all the file types registered with the system, then open that file type, then open its Shell, or ShellEX folder and add a Key, name it whatever you want, Give it the value of a string you want to appear in the shell menu, now give it a child key, call it command, and give it the value of the path you to your application plus any command line args you want to pass to your app, ex, C:\program files\myapp\myapp.exe %1 HKEY_CLASSES_ROOT\Directory\shell\Command\Command where Command = Command Prompt
Command\Command = Cmd.exe /k cd %1

Simple, but things get much more complicated if you want an icon, and you can use classids for your app instead of its path, but that's another, much longer story friend. Hope this has helped you.


Is this a custom file extension, or are you wanting to add a new handler to a common file extension? Take a look at this article:

You have two registry verbs in addition to what Diamonddrake mentioned. You could create your own file extension and register that file extension to your application in your deployment package. There is a special section in VS Deployment Projects for registering file handlers. The "Open With" list is also semi-smart. It learns applications as you go so if you were to manually browser to your application to "Open With" a file then it should remember your application for the next time that dialog is invoked.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.