I want to create my own extension without changing my registry file. I have a VB.NET project, and I first want to create my own extension like ".abc". Afterwards, if there is any file like xxxxxx.abc when a person tries to open this file, I want Windows to start up my project and open that file.
-
4That's not possible. The file type information is stored in the registry. – Guffa Nov 02 '11 at 09:01
1 Answers
The comment above saying that it is impossible is a little misleading. This is impossible to do without changing the registry, but for a clickonce application it is totally possible to do without having to write any code yourself.
When you create a file association in a clickonce application the required information is written to the HKEY_CURRENT_USER hive, and overrides whatever is set at the HKEY_LOCAL_MACHINE level. When your application is uninstalled the file association entries are also removed from HKCU, which means any association already set in HKLM (if any) will be used from then on. IOW you can only override (or set) the file association on a per-user basis.
For more information on how to set the file association, check these links:
- MSDN: How to: Create File Associations For a ClickOnce Application
- Stack Overflow: How do you set up a file association with a click-once application?
- Stack Overflow: ClickOnce File Association
Note that there is also a dialog built into VS2010 to help set this up:
- right click on the project in the Solution Explorer, select Properties
- select the Publish tab
- select the Options button
- select the File Associations option