Sign in to follow this  
DragonGeo2

File Batch-Opening

Recommended Posts

How do I make it possible for my program to be assigned to a filetype. Example - when you instally WinRAR to your computer, it automatically sets it up so that whenever a file of that type is double-clicked, winrar.exe is executed, but how does WinRAR know which file to open? Is there a command line (argc / argv) thing that I'm missing here?

Share this post


Link to post
Share on other sites
When you install WinRAR or other programs that takes over handling certain file extensions, one of the things it does is make changes to the registry. Let's say you want your program to handle the extension .myfile. First you would create a key HKEY_CLASSES_ROOT\.myfile and add a REG_SZ value with the name of your handler. This can be any string, but in practice you name it similarly to your application. In this case we'll call it MyFileApp. Then you create another key HKEY_CLASSES_ROOT\MyFileApp and give it a REG_SZ value that describes the handler. We could call it "My File Handler". Then you create a subkey of HKEY_CLASSES_ROOT\MyFileApp HKEY_CLASSES_ROOT\MyFileApp\open. This doesn't require a value, but does require a subkey HKEY_CLASSES_ROOT\MyFileApp HKEY_CLASSES_ROOT\MyFileApp\open\command. This you give a value equal to the command string for invoking your application. It might be C:\MyFolder\MyApp.exe "%1".

Share this post


Link to post
Share on other sites
For clarification - where can I find code on how to add/modify registry values, and thank you, for help on the matter of how to do this. I do recall once browsing the registry out of boredom, and came across a registry path similar to this one, and thought "What does all this mean?". Well, now I know.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this