Docfxit Posted February 14, 2015 Share Posted February 14, 2015 I found a script created by OnePiece at: '?do=embed' frameborder='0' data-embedContent>> Called _RegEnumKeyEx (Lists all subkeys in a specified registry key) Does anyone know why this won't work with my registry key? expandcollapse popup#RequireAdmin #include <Array.au3> $KeyName = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\SW\DiskSuperSpeed_RamDisk_9_0" ;$KeyName = "HKEY_CLASSES_ROOT" ;104718 ;$KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Classes" Global $a1, $b1 $a1 = TimerInit() $b1 = _RegEnumKeyEx($KeyName, 0, "Opti*Components") ; to find HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OptionalComponents $a1 = TimerDiff($a1) _ArrayDisplay($b1, $a1) ; #FUNCTION# ======================================================================================================================== ; Name...........: _RegEnumKeyEx ; Description ...: Lists all subkeys in a specified registry key ; Syntax.........: _RegEnumKeyEx($KeyName[, $iFlag = 0[, $sFilter = "*"]]) ; Parameters ....: $KeyName - The registry key to read. ; $iFlag - Optional specifies Recursion ; |$iFlag = 0 (Default) All Key-SubKeys Recursive Mod ; |$iFlag = 1 All SubKeys Not Recursive Mod ; $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") ; Search the Autoit3 helpfile for the word "WildCards" For details. ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Key-SubKeys returned ; $array[1] = 1st Key\SubKeys ; $array[2] = 2nd Key\SubKeys ; $array[3] = 3rd Key\SubKeys ; $array[n] = nth Key\SubKeys ; Related .......: ; Link ..........: ; Example .......: _RegEnumKeyEx("HKEY_CURRENT_USER\Software\AutoIt v3") ; Note ..........: ; =================================================================================================================================== Func _RegEnumKeyEx($KeyName, $iFlag = 0, $sFilter = "*") If StringRegExp($sFilter, "[\\/:><]|(?s)\A\s*\z") Then Return SetError(1, 0, "") Local $DX_REKI[101] = [100], $DX_REKISN, $BS = "\", $DX_REKNL, $I = 1, $DX_Filter = StringRegExpReplace($sFilter, "[\*\s]+", ""), $DX_REKFilter = "(?i)(" & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace("|" & $sFilter & "|", '\|\h*\|[\|\h]*', "\|"), '[\^\$\(\)\+\[\]\{\}\,\.\]', "\\$0"), "\|([^\*])", "\|^$1"), "([^\*])\|", "$1\$\|"), '\*', ".*"), '^\||\|$', "") & ")" While $I $DX_REKI[$I] += 1 $DX_REKISN = RegEnumKey($KeyName, $DX_REKI[$I]) If @error Then $DX_REKI[$I] = 0 $I -= 1 $KeyName = StringLeft($KeyName, StringInStr($KeyName, "\", 1, -1) - 1) ContinueLoop EndIf If $DX_Filter Then If StringRegExp($DX_REKISN, $DX_REKFilter) Then $DX_REKNL &= @LF & $KeyName & $BS & $DX_REKISN Else $DX_REKNL &= @LF & $KeyName & $BS & $DX_REKISN EndIf If $iFlag Then ContinueLoop $I += 1 If $I > $DX_REKI[0] Then $DX_REKI[0] += 100 ReDim $DX_REKI[$DX_REKI[0] + 1] EndIf $KeyName &= $BS & $DX_REKISN WEnd If Not $DX_REKNL Then Return SetError(2, 0, "") Return StringSplit(StringTrimLeft($DX_REKNL, 1), @LF) EndFunc Thank you, Docfxit Link to comment Share on other sites More sharing options...
DXRW4E Posted February 15, 2015 Share Posted February 15, 2015 (edited) Hi Docfxit, AutoIt Forum ???????recommended RegistryEx.au3 is slower but is more safer RegistryEx.au3 is much faster and more secure in comparison with the SetACL or any other way, with RegistryEx.au3 no need to check and after taking permission of the Registry key and after Edit Registry etc etc and after restore original permissions in poor words with RegistryEx.au3 do not matter if you have or do not have permission of the registry key, _WinAPI_RegOpenKey (always open a Key) and _WinAPI_RegDeleteValue always delete the Value etc etc etc _WinAPI_Reg*** always edit Registry without changing the original security permissionsCiao. Edited February 15, 2015 by DXRW4E Link to comment Share on other sites More sharing options...
Docfxit Posted February 15, 2015 Author Share Posted February 15, 2015 (edited) Thank you for pointing that out. I just can't figure out how to program this function: #RequireAdmin #include <winapireg.au3> If NOT IsDeclared("ERROR_SUCCESS") Then Global Const $ERROR_SUCCESS = 0 $iIndex = 0 $s = 1 Do $subKey[$s] = _WinAPI_RegEnumKey($RegistryEntry3, $iIndex) $iIndex = $iIndex + 1 Until Not ERROR_SUCCESS For $t = 1 To $subKey[0] $MsgBoxText = $MsgBoxText & $t & " " & $subKey[$i] & @CRLF Next error: ERROR_SUCCESS(): undefined function. Thanks, Docfxit Edited February 15, 2015 by Docfxit Link to comment Share on other sites More sharing options...
DXRW4E Posted February 15, 2015 Share Posted February 15, 2015 (edited) Hi Docfxit 1 - What is $RegistryEntry3 ??? you have to give a concrete example of what you want to do ??, because in the code you're using the $RegistryEntry3 will have to be a registry handle, and I do not think is so 2 - I'll have suggested Many Times for Many Reasons to use the RegistryEx.au3 ????????? 3 - What we do not understand or difficult here ????? expandcollapse popup#include "RegistryEx.au3" #include <Array.au3> Local $sRegKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Adobe", $aRegKey $aRegKey = _WinAPI_RegEnumKeyEx(Null, $sRegKeyPath) If Not @Error Then _ArrayDisplay($aRegKey) EndIf ;;;; from _WinAPI_RegEnumKeyEx parameter ; $iFlags - Optional specifies Recursion (add the flags together for multiple operations): ; |$iFlags = 0 (Default) All Key-SubKeys Recursive Mod ; |$iFlags = 1 All SubKeys Not Recursive Mod ; |$iFlags = 2 Disable the return the count in the first element - effectively makes the array 0-based (must use UBound() ; | to get the size in this case). By Default the first element ($array[0]) contains the number of ; | keys\subkeys\values returned, the remaining elements ($array[1], $array[2], etc.) ; | These flags are ignored by 32-bit Windows ; |$iFlags = 256 operate on the 64-bit registry view, $KEY_WOW64_64KEY (256) ; |$iFlags = 512 operate on the 32-bit registry view, $KEY_WOW64_32KEY (512) $aRegKey = _WinAPI_RegEnumKeyEx(Null, $sRegKeyPath, 1) ; All SubKeys Not Recursive Mod If Not @Error Then _ArrayDisplay($aRegKey) EndIf $aRegKey = _WinAPI_RegEnumKeyEx(Null, $sRegKeyPath, 1 + 2) ; All SubKeys Not Recursive Mod + Disable the return the count in the first element If Not @Error Then _ArrayDisplay($aRegKey) EndIf $aRegKey = _WinAPI_RegEnumKeyEx(Null, $sRegKeyPath, 0 + 256) ; All Key-SubKeys Recursive Mod + operate on the 64-bit registry view If Not @Error Then _ArrayDisplay($aRegKey) EndIf local $aRegValue = _WinAPI_RegEnumValueEx(Null, $sRegKeyPath) If Not @Error Then _ArrayDisplay($aRegValue) Else MsgBox(0, 1, @Error) EndIf ;;;; Or Local $hKey, $sSubKey, $dwIndex = 0 $hKey = _WinAPI_RegOpenKey(Null, $sRegKeyPath, $KEY_ALL_ACCESS + 256) ;$KEY_WOW64_64KEY (256) If Not @Error Then Do $sSubKey = _WinAPI_RegEnumKey($hKey, $dwIndex) $dwIndex += 1 Until @Error EndIf _WinAPI_RegCloseKey($hKey) ;;;; Or $dwIndex = 0 $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, "SOFTWARE\Adobe", $KEY_ALL_ACCESS) While (Not @Error) $sSubKey = _WinAPI_RegEnumKey($hKey, $dwIndex) $dwIndex += 1 WEnd _WinAPI_RegCloseKey($hKey) Ciao. Edited February 15, 2015 by DXRW4E Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now