| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 662 人关注过本帖
标题:[求助]读取注册表,出来的值全是空值
只看楼主 加入收藏
swl7758
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-9-9
收藏
 问题点数:0 回复次数:3 
[求助]读取注册表,出来的值全是空值

Private Sub form_click()
Dim hKey As Long
Dim keytype As Long
Dim keydata As String

keydata = Space(255)
buffesize = 255

RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\TENCENT\QQ", hKey


RegQueryValue hKey, "install", ByVal keydata, buffesize

MsgBox keytype

RegCloseKey hKey

End Sub
谢谢!

搜索更多相关主题的帖子: 注册表 hKey keydata Sub form 
2007-09-18 14:48
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
Option Explicit
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 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 RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002

Private Sub Form_Load()
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
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, 1, ByVal sValue, lenValue)
MsgBox sValue
End If
RegCloseKey hkey
End Sub


我的msn: myfend@
2007-09-18 15:06
swl7758
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-9-9
收藏
得分:0 

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

2007-09-20 10:51
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
嗯 .好.不错.

我的msn: myfend@
2007-09-20 11:16
快速回复:[求助]读取注册表,出来的值全是空值
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024098 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved