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.

Recommended Answers

All 2 Replies

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
and
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:
http://msdn.microsoft.com/en-us/library/bb166549.aspx

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.