|
|
|
Junior Member
      
участник
Last Login: 25.05.2000 20:41
Сообщ.: 10,
Visits: 111
|
|
В моей функции приведенной ниже постоянно возникает ошибка при использовании
RegEnumeValue из библиотеки advapi32.dll, при чем только при обращении к
ключю
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion"
по индексу значения - 31 ( у меня это бинарное значение "DigitalProductId")
в чем может быть дело?
Где я ошибся, уже все перепробовал ничего не могу понять!
Function FindSubVal(Path As String, inD As Long, lpName As String, lpData As
String, lpType As Long) As Long
Dim lpcData As Long, dt As Long, lpcName As Long
Call ParseKey(Path, MainKeyHandle)
RegOpenKeyEx MainKeyHandle, Path, 0, KEY_ALL_ACCESS, hKey
If MainKeyHandle Then
RegQueryInfoKey hKey, mclass, m_MaxClass, m_Reserved, i, m_MaxSubKey, _
m_Maxclasslen, m_Val, m_MaxValNameLen, m_MaxValLen, m_SecID, m_LastTime
'If rtn = ERROR_SUCCESS Then
lpName = Space(m_MaxValNameLen)
lpcData = m_MaxValLen - 1
rtn = RegEnumValue(hKey, inD, lpName, Len(lpName), 0, _
lpType, dt, lpcData) 'open the key
' ReDim dt(lpcData)
rtn = RegEnumValue(hKey, inD, lpName, Len(lpName), 0, _
lpType, dt, lpcData) 'open the key
If rtn = ERROR_SUCCESS Then 'if the key was open successfully then
lpName = Left(lpName, InStr(1, lpName, Chr(0)) - 1)
'lpData = sBuffer
FindSubVal = inD + 1
RegCloseKey (hKey)
End If
'End If
End If
End Function
дополнительно вазываются функции:
Private Sub ParseKey(KeyName As String, Keyhandle As Long)
rtn = InStr(KeyName, "\") 'return if "\" is contained in the Keyname
If Left(KeyName, 5) <> "HKEY_" Or Right(KeyName, 1) = "\" Then 'if the is a
"\" at the end of the Keyname then
MsgBox "Incorrect Format:" + Chr(10) + Chr(10) + KeyName 'display error
to the user
Exit Sub 'exit the procedure
ElseIf rtn = 0 Then 'if the Keyname contains no "\"
Keyhandle = GetMainKeyHandle(KeyName)
KeyName = "" 'leave Keyname blank
Else 'otherwise, Keyname contains "\"
Keyhandle = GetMainKeyHandle(Left(KeyName, rtn - 1)) 'seperate the
Keyname
KeyName = Right(KeyName, Len(KeyName) - rtn)
End If
End Sub
Function GetMainKeyHandle(MainKeyName As String) As Long
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_PERFORMANCE_DATA = &H80000004
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_DYN_DATA = &H80000006
Select Case MainKeyName
Case "HKEY_CLASSES_ROOT"
GetMainKeyHandle = HKEY_CLASSES_ROOT
Case "HKEY_CURRENT_USER"
GetMainKeyHandle = HKEY_CURRENT_USER
Case "HKEY_LOCAL_MACHINE"
GetMainKeyHandle = HKEY_LOCAL_MACHINE
Case "HKEY_USERS"
GetMainKeyHandle = HKEY_USERS
Case "HKEY_PERFORMANCE_DATA"
GetMainKeyHandle = HKEY_PERFORMANCE_DATA
Case "HKEY_CURRENT_CONFIG"
GetMainKeyHandle = HKEY_CURRENT_CONFIG
Case "HKEY_DYN_DATA"
GetMainKeyHandle = HKEY_DYN_DATA
End Select
End Function
Function ErrorMsg(lErrorCode As Long) As String
'If an error does accurr, and the user wants error messages displayed, then
'display one of the following error messages
Select Case lErrorCode
Case 1009, 1015
GetErrorMsg = "The Registry Database is corrupt!"
Case 2, 1010
GetErrorMsg = "Bad Key Name"
Case 1011
GetErrorMsg = "Can't Open Key"
Case 4, 1012
GetErrorMsg = "Can't Read Key"
Case 5
GetErrorMsg = "Access to this key is denied"
Case 1013
GetErrorMsg = "Can't Write Key"
Case 8, 14
GetErrorMsg = "Out of memory"
Case 87
GetErrorMsg = "Invalid Parameter"
Case 234
GetErrorMsg = "There is more data than the buffer has been
allocated to hold."
Case Else
GetErrorMsg = "Undefined Error Code: " & Str$(lErrorCode)
End Select
End Function
З.Ы. Переменные обявленны в модуле по тому типу который нужен.
|
|
|
|
|
Junior Member
      
участник
Last Login: 29.06.2000 21:24
Сообщ.: 15,
Visits: 166
|
|
| Щото я у тебя не вижу использование RegEnumeValue.
|
|
|
|