'make a new project: one form with a commandcontrol
'insert the code on the right places
'make the nessecary changes concerning your application and extension
'look for the * sign!
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
Private sub
Command1_Click()
dim
sKeyName As String 'Holds Key name
in registry.
dim
sKeyValue As String 'Holds Key Value in registry.
dim
ret& 'Holds error status
if any from API calls.
dim
lphKey& 'Holds created key handle from RegCreateKey.
'This creates a root
entry called "MyApp".
sKeyName = "MyApp" '*
sKeyValue = "My Application" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
'This creates a root
entry called .BAR associated with "MyApp".
sKeyName = ".bar" '*
sKeyValue = "MyApp" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
'This sets
the command line for "MyApp".
sKeyName = "MyApp" '*
sKeyValue = "notepad.exe %1" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)
End Sub
Return