Hola!
Solo decir que el código no es mio, lo encontré navegando, buscando otras cosas...
¿Como asociar un fichero a un programa determinado ? '************************************************************
'Windows API/Global Declarations for :AssociateFileType '************************************************************
Declare Function RegCreateKey& Lib "advapi32.DLL" Alias "_
RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&)
Declare Function RegSetValue& Lib "advapi32.DLL" _
Alias "RegSetValueA" (ByVal hKey&, ByVal lpszSubKey$, _
ByVal fdwType&, ByVal lpszValue$, ByVal dwLength&)
' Return codes from Registration functions.
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_BADDB = 1&
Public Const ERROR_BADKEY = 2&
Public Const ERROR_CANTOPEN = 3&
Public Const ERROR_CANTREAD = 4&
Public Const ERROR_CANTWRITE = 5&
Public Const ERROR_OUTOFMEMORY = 6&
Public Const ERROR_INVALID_PARAMETER = 7&
Public Const ERROR_ACCESS_DENIED = 8&
Global Const HKEY_CLASSES_ROOT = &H80000000
Public Const MAX_PATH = 256&
Public Const REG_SZ = 1
'************************************************************
' RUTINA QUE LE PERMITE ASOCIAR UN DETERMINADO
' TIPO DE FICHERO A UN PROGRAMA
' ASOCIA UN FICHERO CON EL BLOC DE NOTAS
' SE PUEDE CAMBIAR PARA ASOCIAR LOS QUE VD. QUIERA '************************************************************
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_BADDB = 1&
Public Const ERROR_BADKEY = 2&
Public Const ERROR_CANTOPEN = 3&
Public Const ERROR_CANTREAD = 4&
Public Const ERROR_CANTWRITE = 5&
Public Const ERROR_OUTOFMEMORY = 6&
Public Const ERROR_INVALID_PARAMETER = 7&
Public Const ERROR_ACCESS_DENIED = 8&
Global Const HKEY_CLASSES_ROOT = &H80000000
Public Const MAX_PATH = 256&
Public Const REG_SZ = 1
Private Sub Command1_Click()
Dim sKeyName As String ' NOMBRE DE LA CLAVE A REGISTRAR
Dim sKeyValue As String ' NOMBRE DEL VALOR A REGISTRAR
Dim ret& ' ERROR DEVUELTO POR LAS LLAMADAS A LA API
Dim lphKey& ' HANDLE A LA CREACION DE REGTKEY
sKeyName = "MyApp"
sKeyValue = "My Application"
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
' CREA UNA ENTRADA EN LA RAIZ LLAMADA .BAR PARA ASOCIALARLA CON "MyApp".
sKeyName = ".bar" '*
sKeyValue = "MyApp" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
' LINEA DE MANDATO "MyApp".
sKeyName = "MyApp" '*
sKeyValue = "notepad.exe %1" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "shellopencommand", REG_SZ, sKeyValue, MAX_PATH)
End Sub