同意楼上.是呀,注册表编辑的那些API里都没这个功能^
纳闷中……
纳闷中……
解决方案 »
- VB 如何把string型变量转换为窗体的名称
- 我在PowerPoint 2003中做成了ppt文件,准备拿到会议上去汇报。到会议上,是在PowerPoint环境中打开进行会议汇报,还是转换成什么格式进行汇报?大家平时都是如何把ppt文件拿到会议上汇报的,
- 如何让代码停止一段时间再继续执行
- 关于标签控件的疑问,恳请指点,十分感谢!
- 介绍点学习vb的资料吧
- 如何用VB编写一个DLL文件,然后再编写一个VB程序调用那个DLL中的函数
- VB的大发现!!!!
- 查找win9x注册表啊!高手请进!
- VB ActiveX EXE 问题,不太难
- 每一个TEXT的_GotFocus()事件都返回自己的name
- sql语句统计问题,请高手指教
- 怎样在datareport中令正数为蓝负数为红
Public Function EnumKey(hMainKey As Long, sSubKey As String, lIndex As Long, lpStr As String) As Boolean
'EnumKey函数打开有hMainKey主键和sSubKey子键指定的注册键,lIndex为要查询的子键值
'的索引,lpStr为放置子键值的字符串缓冲,如果要查询一个键值的所有子键,只要将lIndex
'首先设置为0,然后将lIndex递增1再调用EnumKey函数,直到函数返回0为止
Dim hKey As Long '打开键的句柄
Dim I As Long
If RegOpenKey(hMainKey, sSubKey, hKey) = ERROR_SUCCESS Then
lpStr = Space(255) + Chr(0)
Debug.Print Len(lpStr)
If RegEnumKey(hKey, lIndex, lpStr, Len(lpStr)) = ERROR_SUCCESS Then
EnumKey = True
Else
EnumKey = False
End If
Else
EnumKey = False
End If
RegCloseKey hKey
End Function
Public Function DeleteKey(lPredefinedKey As Long, sKeyName As String)
'DeleteKey函数打开有hPredfineKeyKey主键和sKeyName子键指定的注册键,再将此子键删除
Dim lRetVal As Long
Dim hKey As Long '打开键的句柄
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegDeleteKey(lPredefinedKey, sKeyName)
RegCloseKey (hKey)
End FunctionPublic Function DeleteValue(lPredefinedKey As Long, sKeyName As String, sValueName As String)
'DeleteValue函数删除一个值
Dim lRetVal As Long
Dim hKey As Long '打开键的句柄
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegDeleteValue(hKey, sValueName)
RegCloseKey (hKey)
End FunctionPublic Function SetValueEx(ByVal hKey As Long, sValueName As String, lType As Long, vValue As Variant) As Long
'SetValueEx函数设置值
'如果参数为REG_SZ则设置的值为字符串
'如果参数为REG_WORD设置的值为整数值
Dim lValue As Long
Dim sValue As String Select Case lType
Case REG_SZ
sValue = vValue
SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, sValue, Len(sValue))
Case REG_DWORD
lValue = vValue
SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, lType, lValue, 4)
End Select
End FunctionFunction QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long
Dim cch As Long
Dim lrc As Long
Dim lType As Long
Dim lValue As Long
Dim sValue As String On Error GoTo QueryValueExError lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
If lrc <> ERROR_NONE Then Error 5 Select Case lType
'查询字符串值
Case REG_SZ:
sValue = String(cch, 0)
lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch)
If lrc = ERROR_NONE Then
vValue = Left$(sValue, cch)
Else
vValue = Empty
End If '查询整数值
Case REG_DWORD:
lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch)
If lrc = ERROR_NONE Then vValue = lValue
Case Else
lrc = -1
End SelectQueryValueExExit: QueryValueEx = lrc
Exit FunctionQueryValueExError: Resume QueryValueExExitEnd Function
Public Function CreateNewKey(lPredefinedKey As Long, sNewKeyName As String)
' Description:
' 这个函数建立一个新的键
Dim hNewKey As Long '打开新键的句柄
Dim lRetVal As Long
lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
RegCloseKey (hNewKey)
End FunctionPublic Function SetKeyValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long)
Dim lRetVal As Long
Dim hKey As Long '打开键的句柄 lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
RegCloseKey (hKey)
End FunctionPublic Function QueryValue(lPredefinedKey As Long, sKeyName As String, sValueName As String)
Dim lRetVal As Long
Dim hKey As Long '打开键的句柄
Dim vValue As Variant 'setting of queried value
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = QueryValueEx(hKey, sValueName, vValue)
QueryValue = vValue
RegCloseKey (hKey)
End Function