How do I associate a File Extension with my application?
All the file type-app associations are stored in the Registry. To create a file extension associated with your application, you need to write a Registry Key to register it.
For example: Creating a file extension named .Hello.
Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)
Explanation to above code sample:
What it does
Creates a registry key in ClassesRoot for the .Hello extension. Notice that you must include the beginning period.
1. "" (Or Nothing) sets the default value of the key.
2. "Hello" is like the "txtfile" we saw earlier; it tells which registry key contains the information about the .Hello extension.
CreateSubKey("Hello" & _ "\shell\open\command")
This creates the "Hello" sub-key and the "store\open\command" subkey that is needed to store the path to the application that will open this file type.
.SetValue("", Application.ExecutablePath & _ " ""%l"" ",...
1. Again, "" tells the application to set the key's default value.
2. Application.ExecutablePath tells the code to associate the currently running executablewith this file type.
3. " ""%1"" " passes the opened file's location to your program. The quotes around it areoptional, but if you have more than one argument, you must put them around each.
Detailed walkthrough and demo project can be found here:
Additionally, you can manually create a file extension via Windows Explorer:
Tools menu -> Folder Options -> File Types -> Create New Extension by specifying File Extension and Associated File Type.
For more FAQ about Visual Basic .NET General, please see Visual Basic .NET General FAQ
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?