Shrikant Posted August 11, 2006 Posted August 11, 2006 Following VBScript code gives me count of registry entry in specified folder... const HKEY_CURRENT_USER = 2147483649 Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" oReg.EnumValues HKEY_CURRENT_USER, strKeyPath,arrValueNames, arrValueTypes MsgBox UBound(arrValueNames) AutoIt code for the same is ......... Const $HKEY_CURRENT_USER = 2147483649 $oReg=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") $strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" $oReg.EnumValues $HKEY_CURRENT_USER, $strKeyPath,$arrValueNames, $arrValueTypes MsgBox(0,"Count", UBound($arrValueNames)) After executing code it gives me following error--- E:\Program Files\AutoIt3\Include\RegistryCount.au3(5,18) : ERROR: syntax error $oReg.EnumValues $HKEY_CURRENT_USER ~~~~~~~~~~~~~~~~~^ E:\Program Files\AutoIt3\Include\RegistryCount.au3 - 1 error(s), 0 warning(s)
GaryFrost Posted August 11, 2006 Posted August 11, 2006 (edited) Enum $HKEY_CLASSES_ROOT = 0x80000000, $HKEY_CURRENT_USER, $HKEY_LOCAL_MACHINE, $HKEY_USERS, $HKEY_CURRENT_CONFIG, $HKEY_DYN_DATA local $arrValueNames, $arrValueTypes $oReg=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") $strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" $oReg.EnumValues($HKEY_CURRENT_USER, $strKeyPath, $arrValueNames, $arrValueTypes) MsgBox(0,"Count", UBound($arrValueNames)) Edited August 11, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GaryFrost Posted August 11, 2006 Posted August 11, 2006 (edited) after playing around with this a bit, thought i would make a function out of it. expandcollapse popupOpt("MustDeclareVars", 1) _Main() Func _Main() Local $a_keys = _RegEnumValues(".", "HKLM", "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"), $x ;~ Local $a_keys = _RegEnumValues(".", "HKLM", "test"), $x If Not @error Then For $x = 0 To UBound($a_keys) - 1 ConsoleWrite($a_keys[$x][0] & " : " & $a_keys[$x][1] & " : " & $a_keys[$x][2] & @LF) Next EndIf EndFunc ;==>_Main ;=============================================================================== ; ; Description: _RegEnumValues ; Parameter(s): computer name - string of remote computer or "." for current computer ; registry tree - contains the sSubKeyName path ; sub key name - A path that contains the named values to be enumerated ; Requirement: None ; Return Value(s): Returns a multi-dimensional array ([0] = key name, [1] = key value, [2] = key type) ; If an error occurs @error is set and 0 is returned ; User CallTip: _RegEnumValues(computer name, registry tree, sub key name) Enumerates the values of the given subkey ; Author(s): Gary Frost (custompcs at charter dot net) ; Note(s): A registry tree can be one of: ; "HKEY_LOCAL_MACHINE" ("HKLM") ; "HKEY_USERS" ("HKU") ; "HKEY_CURRENT_USER" ("HKCU") ; "HKEY_CLASSES_ROOT" ("HKCR") ; "HKEY_CURRENT_CONFIG" ("HKCC") ; ;=============================================================================== Func _RegEnumValues($strComputer, $s_hDefKey, $strKeyPath) Local $hDefKey, $x Enum $HKEY_CLASSES_ROOT = 0x80000000, $HKEY_CURRENT_USER, $HKEY_LOCAL_MACHINE, $HKEY_USERS, $HKEY_CURRENT_CONFIG If $strComputer = "." Then $strComputer = @ComputerName Switch StringUpper($s_hDefKey) Case "HKEY_LOCAL_MACHINE", "HKLM" $hDefKey = $HKEY_LOCAL_MACHINE Case "HKEY_USERS", "HKU" $hDefKey = $HKEY_USERS Case "HKEY_CURRENT_USER", "HKCU" $hDefKey = $HKEY_CURRENT_USER Case "HKEY_CLASSES_ROOT", "HKCR" $hDefKey = $HKEY_CLASSES_ROOT Case "HKEY_CURRENT_CONFIG", "HKCC" $hDefKey = $HKEY_CURRENT_CONFIG Case Else Return SetError(1, 1, 0) EndSwitch Local $a_Type[8] = [7, "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY", "REG_DWORD", "", "", "REG_MULTI_SZ"] Local $arrValueNames, $arrValueTypes Local $oReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\default:StdRegProv") $oReg.EnumValues ($HKEY_LOCAL_MACHINE, $strKeyPath, $arrValueNames, $arrValueTypes) If Not IsArray($arrValueNames) Then Return SetError(2, 2, 0) Local $a_ret[UBound($arrValueNames) ][3] For $x = 0 To UBound($arrValueNames) - 1 $a_ret[$x][0] = $arrValueNames[$x] $a_ret[$x][1] = RegRead($s_hDefKey & "\" & $strKeyPath, $arrValueNames[$x]) $a_ret[$x][2] = $a_Type[$arrValueTypes[$x]] Next Return $a_ret EndFunc ;==>_RegEnumValues Edited August 11, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Moderators SmOke_N Posted August 11, 2006 Moderators Posted August 11, 2006 Holy cow that's fast!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Micha1405 Posted September 27, 2006 Posted September 27, 2006 Nice Script but it does not work with regtyp REG_QWORD (it is 64bit) @gafrost: do have a idea to fix it ?? My TrayToolBar
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