Imports Microsoft.Win32
Module Module1
Private Sub Main()
Dim appName As String = "YourAppName"
Dim appPath As String = "C:\Path\To\YourApp.exe"
' Set the default application for .jpg files
SetDefaultApp(".jpg", appName, appPath)
' Set the default application for .png files
SetDefaultApp(".png", appName, appPath)
' Set the default application for .bmp files
SetDefaultApp(".bmp", appName, appPath)
End Sub
Private Sub SetDefaultApp(extension As String, appName As String, appPath As String)
Dim key As RegistryKey = Registry.ClassesRoot.CreateSubKey(extension)
key.SetValue("", appName)
Dim appKey As RegistryKey = Registry.ClassesRoot.CreateSubKey(appName)
appKey.SetValue("", "Image File")
appKey.CreateSubKey("shell\open\command").SetValue("", """" & appPath & """ ""%1""")
End Sub
End Module