Article ID: 119281
Article Last Modified on 12/9/2003
Declare Function RegCreateKey& Lib "SHELL.DLL" (ByVal hKey&, ByVal lpszSubKey$, lphKey&) Declare Function RegSetValue& Lib "SHELL.DLL" (ByVal hKey&, ByVal lpszSubKey$, ByVal fdwType&, ByVal lpszValue$, ByVal dwLength&) ' Return codes from Registration functions. Const ERROR_SUCCESS = 0& Const ERROR_BADDB = 1& Const ERROR_BADKEY = 2& Const ERROR_CANTOPEN = 3& Const ERROR_CANTREAD = 4& Const ERROR_CANTWRITE = 5& Const ERROR_OUTOFMEMORY = 6& Const ERROR_INVALID_PARAMETER = 7& Const ERROR_ACCESS_DENIED = 8& Const HKEY_CLASSES_ROOT = 1 Const MAX_PATH = 256& Const REG_SZ = 1
Sub Form_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 = "c:\mydir\my.exe %1"
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue,
MAX_PATH)
End Sub
.bar = MyApp
MyApp = My Application
|
-- Shell
|
-- open
|
-- command = c:\mydir\my.exe %1
If you are running Windows NT, choose File Run (Alt+F, R) on the Program
Manager and type "REGEDT32". This will run the registration database
editor for Windows NT. The .BAR and MyApp entries can be found under
the HKEY_CLASSES_ROOT on your local machine.
Additional query words: kbdsd
Keywords: kbhowto kbregistry KB119281