修改注删表
王国荣《VB6与WinApi》例子
只有一个Module1
启动模块设为Sub Main修改一下就可以了============Module1==========================
Option ExplicitPublic Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_EXPAND_SZ = 2
Public Const REG_BINARY = 3
Public Const REG_DWORD = 4
Public Const REG_DWORD_BIG_ENDIAN = 5
Public Const REG_MULTI_SZ = 7Public Const MAX_PATH = 260Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongSub Main()
    Dim hKey As Long, PathName As String
    Dim NotepadDir As String, IconDir As String    PathName = App.Path
    If Right(PathName, 1) <> "\" Then PathName = PathName & "\"
    IconDir = PathName & "Note03.ico,0"
    PathName = PathName & "kjTest.exe %1"
    
    NotepadDir = String(MAX_PATH, Chr(0))
    GetWindowsDirectory NotepadDir, Len(NotepadDir)
    NotepadDir = Left(NotepadDir, InStr(NotepadDir, Chr(0)) - 1)
    If Right(NotepadDir, 1) <> "\" Then NotepadDir = NotepadDir & "\"
    NotepadDir = NotepadDir & "Notepad.EXE /p %1"    hKey = HKEY_CLASSES_ROOT
    RegSetValue hKey, ".kj", REG_SZ, "kjFile", 7
    RegSetValue hKey, "kjFile", REG_SZ, "kj文本文件", 9
    RegSetValue hKey, "kjFile\shell", REG_SZ, "open", 5
    RegSetValue hKey, "kjFile\shell\open\command", REG_SZ, _
                PathName, LenB(StrConv(PathName, vbFromUnicode)) + 1
    RegSetValue hKey, "kjFile\shell\print\command", REG_SZ, _
                NotepadDir, LenB(StrConv(NotepadDir, vbFromUnicode)) + 1
    RegSetValue hKey, "kjFile\DefaultIcon", REG_SZ, _
                IconDir, LenB(StrConv(IconDir, vbFromUnicode)) + 1
    RegCloseKey hKey
    
    MsgBox "扩展名 .kj 已经设定妥当!"
End Sub