[VB6.0]注册表编程方面的问题:读取注册表项指定名称的值的数据
谁能给我看看代码哪里有错,我是想实现一个读取注册表项指定名称的值的数据?可由于没有达到我想要的功能,所以来请教帮我看看了!Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal _
lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, 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
Dim key As Long
Private Sub Command1_Click()
Dim pkey As Long
Dim a(1 To 5) As String
Dim Name As String
Dim ret As Long
Dim lendata As Long
Dim typedata As Long
ret = RegOpenKeyEx(&H80000001, "Software\Microsoft\IMEMIP", 0, 0, pkey)
'If ret <> 0 Then Exit Sub
a(1) = "Converted"
a(2) = "IDEdit"
a(3) = "Input"
a(4) = "TargetConverted"
a(5) = "TargetNotConverted"
For i = 1 To UBound(a)
Name = a(i)
ret = RegQueryValueEx(pkey, Name, 0, typedata, ByVal vbNullString, lendata)
If ret <> 0 Then
RegCloseKey pkey
Exit Sub
End If
Select Case typedata
Case 1, 2, 7
Dim s As String
s = String(lendata, Chr(0))
RegQueryValueEx pkey, Name, 0, typedata, ByVal s, lendata
If typedata = 1 Then
s = Left(s, InStr(s, Chr(0)) - 1)
Text3.SelText = s & vbCrLf
End If
Case 4, 5
Dim q As Long
RegQueryValueEx pkey, Name, 0, typedata, q, lendata
Text3.SelText = Name & "=" & q & vbCrLf
End Select
Next
RegCloseKey pkey
End Sub
--------------------编程问答-------------------- http://www.m5home.com/bbs/dispbbs.asp?boardid=28&Id=422&page=2
用我这个封装好的模块吧 --------------------编程问答-------------------- 楼主没有说清楚有什么样的问题,没法帮你,
有一种可能性,如果你访问的哪些键值不存在,肯定就有问题
补充:VB , 基础类