JumpyNET
Well-known member
- Joined
- Apr 4, 2005
- Messages
- 151
It took me a while to find this information, so I though Id post it here incase it might save some time for some one else.
Heres a simple code example:
After running the code go to:
Start --> Control Panel --> Default Programs --> Set your default programs --> Choose your exe --> Choose defaults for this program --> Select files to associate --> Save
More info about this can be found on msdn:
http://msdn.microsoft.com/en-us/library/bb776873.aspx
They also mentioned some functions related to this, but I couldnt figure out how to call them. So if any of you nows how to call these functions, then please tell: LaunchAdvancedAssociationUI & SetAppAsDefaultAll
Heres a simple code example:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AppPath As String = """" & Application.ExecutablePath & """" & " ""%1"""
Dim IconStr As String = "shell32.dll,116"
What to do with mp3-files (icon, open command etc.)
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocFile.MP3", "", "MP3 Format Sound")
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocFile.MP3\DefaultIcon", "", IconStr)
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocFile.MP3\shell\open\command", "", AppPath)
What to do with mms-urls (icon, open command etc.)
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocProtocol.MMS", "", "URL:MMS Protocol")
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocProtocol.MMS", "URL Protocol", "")
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocProtocol.MMS\DefaultIcon", "", IconStr)
SaveToRegistry("SOFTWARE\Classes\Litware.Player.AssocProtocol.MMS\shell\open\command", "", AppPath)
What kind of files are we capable of handling
SaveToRegistry("SOFTWARE\Litware\Litware Player\Capabilities", "ApplicationDescription", "The new Litware Media Player breaks new ground in exciting fictional programs.")
SaveToRegistry("SOFTWARE\Litware\Litware Player\Capabilities\FileAssociations", ".mp3", "Litware.Player.AssocFile.MP3")
SaveToRegistry("SOFTWARE\Litware\Litware Player\Capabilities\URLAssociations", "mms", "Litware.Player.AssocProtocol.MMS")
Register to Default Programs
SaveToRegistry("SOFTWARE\RegisteredApplications", "Litware Player", "Software\Litware\Litware Player\Capabilities")
End Sub
Saves a value name with its data and parent key in the registry
Public Sub SaveToRegistry(ByVal KeyPath As String, ByVal ValueName As String, ByVal ValueData As Object)
Dim regKey As Microsoft.Win32.RegistryKey
Open the key with write access
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(KeyPath, True)
If not found, create the key
If regKey Is Nothing Then
Create a key in HKEY_LOCAL_MACHINE\[Path]
regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(KeyPath)
End If
Set the new value
regKey.SetValue(ValueName, ValueData)
End Sub
After running the code go to:
Start --> Control Panel --> Default Programs --> Set your default programs --> Choose your exe --> Choose defaults for this program --> Select files to associate --> Save
More info about this can be found on msdn:
http://msdn.microsoft.com/en-us/library/bb776873.aspx
They also mentioned some functions related to this, but I couldnt figure out how to call them. So if any of you nows how to call these functions, then please tell: LaunchAdvancedAssociationUI & SetAppAsDefaultAll