• Advertisement
Sign in to follow this  

File Batch-Opening

This topic is 4331 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
RegCreateKeyEx / RegSetValueEx...

Check out MSDN for more information if you're confused...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement