定义我就不写了。你自己加上去吧。
'读取注册表中是否有选定参数
'用法: rValue = RegistryGetKeyValue(rrkHKeyLocalMachine, "software\microsoft\windows\currentversion\run", "法院数据库系统")
Public Function RegistryGetKeyValue(eRootKey As EnumRegistryRootKeys, strKeyName As String, strValueName As String) As Variant
Dim lngRetVal As Long
Dim lngHKey As Long
Dim varValue As Variant
Dim strValueData As String
Dim abytValueData() As Byte
Dim lngValueData As Long
Dim lngValueType As Long
Dim lngDataSize As Long
On Error GoTo PROC_ERR
varValue = Empty
lngRetVal = RegOpenKeyEx(eRootKey, strKeyName, 0&, mcregKeyQueryValue, lngHKey)
If mcregErrorNone = lngRetVal Then
lngRetVal = RegQueryValueExNULL(lngHKey, strValueName, 0&, lngValueType, 0&, lngDataSize)
If lngRetVal = mcregErrorNone Then
If lngDataSize > 0 Then
strValueData = String(lngDataSize, 0)
lngRetVal = RegQueryValueExString(lngHKey, strValueName, 0&, lngValueType, strValueData, lngDataSize)
If InStr(strValueData, vbNullChar) > 0 Then
strValueData = Mid$(strValueData, 1, InStr(strValueData, vbNullChar) - 1)
End If
End If
If mcregErrorNone = lngRetVal Then
varValue = left$(strValueData, lngDataSize)
Else
varValue = Empty
End If
End If
RegCloseKey (lngHKey)
End If
'Return varValue
RegistryGetKeyValue = varValue
Exit Function
PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , "RegistryGetKeyValue"
End Function
'读取注册表中是否有选定参数
'用法: rValue = RegistryGetKeyValue(rrkHKeyLocalMachine, "software\microsoft\windows\currentversion\run", "法院数据库系统")
Public Function RegistryGetKeyValue(eRootKey As EnumRegistryRootKeys, strKeyName As String, strValueName As String) As Variant
Dim lngRetVal As Long
Dim lngHKey As Long
Dim varValue As Variant
Dim strValueData As String
Dim abytValueData() As Byte
Dim lngValueData As Long
Dim lngValueType As Long
Dim lngDataSize As Long
On Error GoTo PROC_ERR
varValue = Empty
lngRetVal = RegOpenKeyEx(eRootKey, strKeyName, 0&, mcregKeyQueryValue, lngHKey)
If mcregErrorNone = lngRetVal Then
lngRetVal = RegQueryValueExNULL(lngHKey, strValueName, 0&, lngValueType, 0&, lngDataSize)
If lngRetVal = mcregErrorNone Then
If lngDataSize > 0 Then
strValueData = String(lngDataSize, 0)
lngRetVal = RegQueryValueExString(lngHKey, strValueName, 0&, lngValueType, strValueData, lngDataSize)
If InStr(strValueData, vbNullChar) > 0 Then
strValueData = Mid$(strValueData, 1, InStr(strValueData, vbNullChar) - 1)
End If
End If
If mcregErrorNone = lngRetVal Then
varValue = left$(strValueData, lngDataSize)
Else
varValue = Empty
End If
End If
RegCloseKey (lngHKey)
End If
'Return varValue
RegistryGetKeyValue = varValue
Exit Function
PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , "RegistryGetKeyValue"
End Function
解决方案 »
- 谁介绍个可以mp3,或者wma混音的dll动态链接库
- vb操作记事本的问题?
- inet控件或webbrowser控件如何禁用cookie而且不影响IE浏览器的cookie功能??
- 一个并不是很难的循环的问题,我却少加了一次,看了3个小时,没看出错误,请大虾来帮忙看一下。
- 求高手:有没有办法扑获窗体上所有的CHECKBOX的CLICK事件,立刻放分
- 请帮我解决问题啊,原贴有100分啊
- 急球 setupfactory 制作安装盘 关于安装语言的问题
- 请教一个很菜的问题?
- 在vb中能否改变inputbox函数所弹出对话框的样子
- 急,数据结构问题
- 有关一个FROM的故事
- 求救:不同的数据库中不同的表,想把其中相关的字段提出来生成一个查询,绑到datagrid上!
While ret = 0
lenName = 256ret = RegEnumValueAsAny2(hKey, idx, bName(0), lenName, ByVal 0, typeData, ByVal vbNullString, lenData)'上面的RegEnumValueAsAny2调用得到了第一个Name的长度lenName,不含chr(0)
Name = String(lenName + 1, Chr(0))
lenName = Len(Name)s = String(lenData, Chr(0))
RegEnumValueAsAny hKey, idx, Name, lenName, ByVal 0, typeData, ByVal s, lenData
s = Left(s, InStr(s, Chr(0)) - 1)
If s <> "" Then
txtserver.AddItem Left(Name, InStr(Name, Chr(0)) - 1) & "(" & s & ")"
End If
idx = idx + 1
Wend
RegCloseKey hKey
End Sub
看看吧
http://www.sqreg.com/file/vb/reg_01.htm
http://www.sqreg.com/file/vb/reg_02.htm
http://www.sqreg.com/file/vb/reg_03.htm
http://www.sqreg.com/file/vb/reg_04.htm
http://www.sqreg.com/file/vb/reg_05.htm
http://www.sqreg.com/file/vb/reg_06.htm
http://www.sqreg.com/file/vb/reg_07.htm