📄 register_file.bas
字号:
Attribute VB_Name = "register_file"
Option Explicit
Const HKEY_CLASSES_ROOT = &H80000000
Private Declare Function OSRegCreateKey Lib "Advapi32" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpszSubKey As String, phkResult As Long) As Long
Const ERROR_SUCCESS = 0&
Const REG_SZ = 1
Private Declare Function OSRegSetValueEx Lib "Advapi32" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpszValueName As String, ByVal dwReserved As Long, ByVal fdwType As Long, lpbData As Any, ByVal cbData As Long) As Long
Public softname As String
Const SW_SHOW = 5
Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Sub regchange(ByVal softname As String)
Dim ret1 As Long, hKey As Long, hkey1 As Long, strdata As String
strdata = "MP3File"
ret1 = OSRegCreateKey(HKEY_CLASSES_ROOT, ".mp3", hKey)
ret1 = OSRegSetValueEx(hKey, "", 0&, REG_SZ, ByVal strdata, LenB(StrConv(strdata, vbFromUnicode)) + 1)
ret1 = OSRegCreateKey(HKEY_CLASSES_ROOT, "MP3File", hKey)
strdata = "MP3文件"
ret1 = OSRegSetValueEx(hKey, "", 0&, REG_SZ, ByVal strdata, LenB(StrConv(strdata, vbFromUnicode)) + 1)
ret1 = OSRegCreateKey(hKey, "DefaultIcon", hkey1)
strdata = softname & ", 0" '应根据具体情况更改路径
ret1 = OSRegSetValueEx(hkey1, "", 0&, REG_SZ, ByVal strdata, LenB(StrConv(strdata, vbFromUnicode)) + 1)
ret1 = OSRegCreateKey(hKey, "shell", hKey)
ret1 = OSRegCreateKey(hKey, "open", hKey)
ret1 = OSRegCreateKey(hKey, "command", hkey1)
strdata = Chr(34) & softname & Chr(34) & Chr(34) & "%1" & Chr(34)
ret1 = OSRegSetValueEx(hkey1, "", 0&, REG_SZ, ByVal strdata, LenB(StrConv(strdata, vbFromUnicode)) + 1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -