1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Option Explicit
..........
Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hkey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
...........
Public Function EnumerationValue(Root&, CheminFind$, Mode As Boolean) As String
Dim valuename As String ' name of the value being retrieved
Dim valuelen As Long ' length of valuename
Dim datatype As Long ' receives data type of value
Dim data(0 To 254) As Byte ' 255-byte data buffer for read information
Dim datalen As Long ' size of data buffer information
Dim datastring As String ' will receive data converted to a string, if necessary
Dim hkey As Long ' handle to the registry key to enumerate the values of
Dim Index As Long ' counter for the index of the value to enumerate
Dim c As Long ' counter variable
Dim retval As Long ' functions' return value
Dim CadrageNom%
Dim CadrageVal%
Dim ListeClef$
ListeClef$ = ""
' Open the registry key to enumerate the values of.
retval = RegOpenKeyEx(Root&, CheminFind$, 0&, KEY_QUERY_VALUE, hkey)
' Check to see if an error occured.
If retval <> 0 Then
' Debug.Print "Registry key could not be opened -- aborting."
EnumerationValue = "? (Listage nom) Il est impossible d'ouvrir la clef !"
Exit Function ' abort
End If
' Begin enumerating the values. Get each one, displaying its name. If it's a null-
' terminated string or binary data, display it. If not, say so.
Index = 0 ' initialize the counter
While retval = 0 ' loop while successful
' Initialize the value name buffer.
valuename = Space(255) ' 255-space buffer
valuelen = 255 ' length of the string
datalen = 255 ' size of data buffer
' Get the next value to be enumerated
RegistreRW!Espion.AddItem "hkey =" & Format$(hkey)
RegistreRW!Espion.AddItem "Index =" & Format$(Index)
RegistreRW!Espion.AddItem "valuename =" & valuename
RegistreRW!Espion.AddItem "valuelen =" & Format$(valuelen)
RegistreRW!Espion.AddItem "datatype =" & Format$(datatype)
RegistreRW!Espion.AddItem "data(0) =" & Format$(data(0))
RegistreRW!Espion.AddItem "datalen =" & Format$(datalen)
retval = RegEnumValue(ByVal hkey, ByVal Index, ByVal valuename, valuelen, &H0, datatype, data(0), datalen)
RegistreRW!Espion.AddItem "RegEnumValue =" & Format$(retval)
If retval = 0 Then ' if successful, display information |
Partager