#Include <Array.au3>
#Include <Constants.au3>
#Include <WinAPIEx.au3>
Global $hKey, $Hive
$hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion')
_RegEnumValues($hKey, $Hive, -1,0,1)
_WinAPI_RegCloseKey($hKey)
$Hive = StringSplit($Hive, ChrW(160))
_ArrayDisplay($Hive)
Func _RegEnumValues($hRoot, ByRef $sData, $iLevel = -1, $iLenght = 0, $iParam = 0, $sParam = 0)
If (($iLevel > -1) And ($iParam > $iLevel)) Or (($iLenght) And (StringLen($sData) > $iLenght)) Then
Return SetError(1, -1, 0)
EndIf
If Not $iParam Then
$sData = ''
EndIf
$iParam += 1
Local $hKey, $sKey, $aKey, $sVal, $aText, $sText, $Quotes, $Size, $Struct, $Type, $Sep = ChrW(160), $Error = 0
Local $tData = DllStructCreate('byte[1048576]')
Local $pData = DllStructGetPtr($tData)
If $sParam Then
$sData &= $sParam & '\' & $Sep
EndIf
$aKey = _WinAPI_RegQueryInfoKey($hRoot)
If @error Then
Return SetError(1, @extended, 0)
EndIf
For $i = 0 To $aKey[2] - 1
$sVal = _WinAPI_RegEnumValue($hRoot, $i)
If @error Then
Return SetError(1, @extended, 0)
EndIf
$Size = _WinAPI_RegQueryValue($hRoot, $sVal, $tData)
If @error Then
Return SetError(1, @extended, 0)
EndIf
$Type = @extended
If Not $sVal Then
$sVal = '@'
EndIf
If Not $Size Then
$sText = ''
Else
Switch $Type
Case $REG_MULTI_SZ
$sText = ''
$aText = _WinAPI_StructToArray($pData)
If @error Then
Return SetError(1, -1, 0)
EndIf
For $j = 1 To $aText[0] - 1
$sText &= $aText[$j] & @LF
Next
If $aText[0] Then
$sText &= $aText[$aText[0]]
EndIf
$Quotes = 1
Case Else
$Quotes = 0
Switch $Type
Case $REG_DWORD, $REG_DWORD_BIG_ENDIAN
$Struct = 'dword'
Case $REG_QWORD
$Struct = 'uint64'
Case $REG_SZ, $REG_EXPAND_SZ
$Struct = 'wchar[' & $Size & ']'
$Quotes = 1
Case Else
$Struct = 'byte[' & $Size & ']'
EndSwitch
$sText = DllStructGetData(DllStructCreate($Struct, $pData), 1)
If $Quotes Then
$sText = '"' & $sText & '"'
EndIf
EndSwitch
EndIf
If $sParam Then
$sData &= $sParam & '\\'
EndIf
$sData &= $sVal & '=(' & $Type & ')' & $sText & $Sep
Next
For $i = 0 To $aKey[0] - 1
$sKey = _WinAPI_RegEnumKey($hRoot, $i)
If @error Then
Return SetError(1, @extended, 0)
EndIf
$hKey = _WinAPI_RegOpenKey($hRoot, $sKey, $KEY_READ)
If @error Then
Return SetError(1, @extended, 0)
EndIf
If $sParam Then
_RegEnumValues($hKey, $sData, $iLevel, $iLenght, $iParam, $sParam & '\' & $sKey)
Else
_RegEnumValues($hKey, $sData, $iLevel, $iLenght, $iParam, $sKey)
EndIf
If @error Then
$Error = @extended
If Not $Error Then
$Error = -1
EndIf
EndIf
_WinAPI_RegCloseKey($hKey)
Next
If $iParam = 1 Then
If Not $Error Then
$sData = StringRegExpReplace($sData, $Sep & '*\Z', '')
Else
$sData = ''
EndIf
EndIf
Return SetError($Error <> 0, $Error, $Error = 0)
EndFunc ;==>_RegEnumValues