Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
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
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_NONE = 0
Private Const REG_SZ = 1 ' 字符串
Private Const REG_EXPAND_SZ = 2 ' 可展开式字符串
Private Const REG_BINARY = 3 ' Binary数据
Private Const REG_DWORD = 4 ' 长整数
Private Const REG_DWORD_BIG_ENDIAN = 5 ' BIG_ENDIAN长整数
Private Const REG_MULTI_SZ = 7 ' 多重字符串
Private Sub command1_click()
Dim hkey As Long
Dim strName As String
Dim ret As Long
Dim sValue As String * 255
Dim lenValue As Long
Dim sName As String
Dim keytype As Long
Dim RegGetKeyValue As String
lenValue = Len(sValue)
sName = "software\tencent\qq"
strName = "Install"
ret = RegOpenKey(HKEY_LOCAL_MACHINE, sName, hkey)
If ret = 0 Then
ret = RegQueryValueEx(hkey, strName, 0, keytype, ByVal sValue, lenValue)
If keytype = 1 Then
RegGetKeyValue = Left$(sValue, lenValue - 1)
Else
RegGetKeyValue = sValue
End If
End If
f$ = RegGetKeyValue & "qq.exe"
x = Shell(f$, 0)
RegCloseKey hkey
End Sub