【VB技巧】VB从注册表读取QQ完整安装路径

  • A+
所属分类:lcx

    VB从注册表读取QQ完整安装路径,VB从注册表读取QQ安装路径,VB读取QQ安装路径,VB取QQ安装路径,VB QQ安装路径,VB QQ 路径,VB QQ。

VB从注册表读取QQ完整安装路径:

Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'返回值: =0,表示成功;≠0,表示失败。[注意这一点与别的API函数不太一样]
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
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Function GetQQPath() As String
    '使用regedit可以查到QQ的位置:HKEY_LOCAL_MACHINESOFTWARETencentQQ
    '键install中的字符串就是安装路径
    Dim ret, lenData, hKey As Long, sValue As String, name As String
    sValue = Space(255)
    Const REG_SZ = 1&                                                           '字符串值
    lenData = 255
    name = "Install"                                                            '在注册表查到的
    ret = 1
    ret = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARETencentQQ", hKey)
    If ret = 0 Then                                                             '正确返回0,不正确返回错误编号
        ret = RegQueryValueEx(hKey, name, 0, REG_SZ, ByVal sValue, lenData)     '注意ByVal千万别忘了
        GetQQPath = sValue
    End If
    ret = RegCloseKey(hKey)
End Function

Private Sub Form_Load()
    MsgBox GetQQPath()
End Sub

文章来源于lcx.cc:【VB技巧】VB从注册表读取QQ完整安装路径

相关推荐: MySQL.Com被SQL注入攻击,用户密码数据被公布

    据来自Sucuri博客的消息,MySQL官方网站MySQL.com被SQL注入攻击(blind SQL injection)。     一篇博客文章(MySQL.com Vulnerable To Blind SQL Injection Vulnera…

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: