You can easily assign a file extension to open with your application in the registry.
The extension is added as a key under “HKEY_CLASSES_ROOT” with the (default) value set to the file’s type (a string arbitrarily assigned by yourself). Then you add a key with the file’s type also to “HKEY_CLASSES_ROOT” with its (default) value set to the file’s type description (that is shown in Exporer). Under the same key, add they keys “shell/open/command” with the (default) value being the program to execute. Use “%1” with the quotes to pass the file’s name to your app. You can also assign an icon by adding a “DefaultIcon” key under the file’s type key. Then additional context menu items can be added by putting keys the [filetype]/shell/[MenuItem]/Command
Example Registry Entries
- HKEY_CLASSES_ROOT\.npost = NovaBlog.Post
- HKEY_CLASSES_ROOT\NovaBlog.Post = NovaBlog Article Posting
- HKEY_CLASSES_ROOT\NovaBlog.Post\DefaultIcon = C:\Program Files\NovaBlog\NovaBlox.exe,0
- HKEY_CLASSES_ROOT\NovaBlog.Post\shell\Open = &Open
- HKEY_CLASSES_ROOT\NovaBlog.Post\shell\Open\Command = C:\Program Files\NovaBlog\NovaBlox.exe “%1”
- HKEY_CLASSES_ROOT\NovaBlog.Post\shell\PostNow = &Post the Article Now
- HKEY_CLASSES_ROOT\NovaBlog.Post\shell\PostNow\Command = C:\Program Files\NovaBlog\NovaBlox.exe /postnow “%1”
Thankfully there is a Microsoft.Win32 namespace with classes for working with the registry. This is all there is to it!