' Case "HKEY_LOCAL_MACHINE": lngKey = &H80000002' Case "HKEY_PERFORMANCE_DATA": lngKey = &H80000004' Case "HKEY_USERS": lngKey = &H80000003' Case Else: Exit Function' End Select' If Not ERROR_SUCCESS = RegOpenKeyEx(lngKey, _' strSubKeys, 0&, KEY_READ, lngHandle) Then Exit Function' lngResult = RegQueryValueEx(lngHandle, strValName, 0&, lngType, ByVal strRet, lngcbData)' strRet = Space(lngcbData)' lngResult = RegQueryValueEx(lngHandle, strValName, 0&, lngType, ByVal strRet, lngcbData)' If Not ERROR_SUCCESS = RegCloseKey(lngHandle) Then lngType = -1&' sdaGetRegEntry = strRet'sdaGetRegEntry_Exit:' On Error GoTo 0' Exit Function''sdaGetRegEntry_Err:' lngType = -1&' MsgBox Err & "> " & Error$, 16, "GenUtils/sdaGetRegEntry"' Resume sdaGetRegEntry_Exit'End Function'Private Function GetRegEntry200(cboStartKey As String, RegistrationPath As String, strValName As String) As Variant' Dim lngType As Long, varRetString As Variant' Dim lngI As Long, intChar As Integer' varRetString = sdaGetRegEntry(cboStartKey, RegistrationPath, strValName, lngType)' If Len(varRetString) Then' For lngI = 1 To Len(varRetString)' intChar = Asc(Mid(varRetString, lngI, 1))' If intChar > 15 Then' GetRegEntry200 = GetRegEntry200 & Hex(intChar) & " "' Else' GetRegEntry200 = GetRegEntry200 & "0" & Hex(intChar) & " "' End If' Next lngI' End If'End Function'Private Function GetRegEntry98(cboStartKey As String, RegistrationPath As String, strValName As String) As Variant' Dim lngType As Long, varRetString As Variant' varRetString = sdaGetRegEntry(cboStartKey, RegistrationPath, strValName, lngType)' GetRegEntry98 = varRetString'End Function'Function sdaGetRegEntry(strKey As String, _' strSubKeys As String, strValName As String, _' lngType As Long) As String' '* Demonstration of win32 API's to query' ' the system registry' ' Stu Alderman -- 2/30/96' On Error GoTo sdaGetRegEntry_Err' Dim lngResult As Long, lngKey As Long' Dim lngHandle As Long, lngcbData As Long' Dim strRet As String' Select Case strKey' Case "HKEY_CLASSES_ROOT": lngKey = &H80000000' Case "HKEY_CURRENT_CONFIG": lngKey = &H80000005' Case "HKEY_CURRENT_USER": lngKey = &H80000001' Case "HKEY_DYN_DATA": lngKey = &H80000006' Case "HKEY_LOCAL_MACHINE": lngKey = &H80000002' Case "HKEY_PERFORMANCE_DATA": lngKey = &H80000004' Case "HKEY_USERS": lngKey = &H80000003' Case Else: Exit Function' End Select' If Not ERROR_SUCCESS = RegOpenKeyEx(lngKey, _' strSubKeys, 0&, KEY_READ, lngHandle) Then Exit Function' lngResult = RegQueryValueEx(lngHandle, strValName, 0&, lngType, ByVal strRet, lngcbData)' strRet = Space(lngcbData)' lngResult = RegQueryValueEx(lngHandle, strValName, 0&, lngType, ByVal strRet, lngcbData)' If Not ERROR_SUCCESS = RegCloseKey(lngHandle) Then lngType = -1&' sdaGetRegEntry = strRet'sdaGetRegEntry_Exit:' On Error GoTo 0' Exit Function''sdaGetRegEntry_Err:' lngType = -1&' MsgBox Err & "> " & Error$, 16, "GenUtils/sdaGetRegEntry"' Resume sdaGetRegEntry_Exit
2006年01月11日 01点01分
4