dufran3 Posted February 13, 2007 Posted February 13, 2007 (edited) I am searching the registry and trying to get all returned results into an array. What is happening, is, I can return the "$currentkey" value, which is what I want to put in the array. But when i try and add it to the array, I try and message box that out, and the Array is empty. Any help? Dim $FileArray[75] $count = 0 SearchReg('HKLM\SOFTWARE\') Func SearchReg($searchpath) For $i= 1 to 10000 $currentkey = RegEnumKey($searchpath, $i) ConsoleWrite($currentkey) If @error <> 0 then ExitLoop $FileArray[$count]=$currentkey $count = $count + 1 MsgBox(0,"","$FileArray[" & $i & "]:" & $FileArray[$i]) Next EndFunc Edited February 13, 2007 by dufran3
dufran3 Posted February 13, 2007 Author Posted February 13, 2007 Dude, you pwned my face. I fixed that, you are awesome. I am not getting all my expected results out of the array. I know you don't want me to ask another question, but I must. This is what I have from your help. I'm trying to assign the $szTzKey globally, because I need to refrence it outside of the function, like here... I tried saying "GLOBAL" but it is saying "WARNING: $szTzKey: possibly used before declaration. If $szTzKey == ~~~~~~~~~~~~^" You are awesome man! If $szTzKey == '' Then MsgBox(0,'','Error: Need to determine wording.') Exit EndIf Func SearchReg($searchpath, $standardname) For $i= 1 to 10000 $currentkey = RegEnumKey($searchpath, $i) If @error <> 0 then ExitLoop ConsoleWrite($currentkey & @CRLF) $arrTZSubKeys[$count]=$currentkey If $currentkey == $standardname Then GLOBAL $szTzKey = $currentkey EndIf MsgBox(0,'','$arrTZSubKeys[' & $count & ']:' & $arrTZSubKeys[$count]) $count = $count + 1 Next EndFunc
dufran3 Posted February 13, 2007 Author Posted February 13, 2007 Whoa, that is a lot of new stuff. I'm not sure I understand what is going on there. Maybe I didn't explain myself very well...happens. The function that I have, is as we both know, searching a registry path. If find subkeys in that path, and adds each one to an array. If the subkey that it is looking in, aka $currentkey, if it matches the $standardname value, which is set outside of the function. I need to do some error checking on the $szTzKey variable. Maybe I shouldn't be assigning the variable in the function? Do you know of any easy way to step through each value in my array, $arrTZSubKeys, and match the $standardname value? All I need, is to call the $szTzKey value, outside of the function. Func SearchReg($searchpath, $standardname) For $i= 1 to 10000 $currentkey = RegEnumKey($searchpath, $i) If @error <> 0 then ExitLoop ConsoleWrite($currentkey & @CRLF) $arrTZSubKeys[$count]=$currentkey If $currentkey == $standardname Then GLOBAL $szTzKey = $currentkey EndIf MsgBox(0,'','$arrTZSubKeys[' & $count & ']:' & $arrTZSubKeys[$count]) $count = $count + 1 Next EndFunc
dufran3 Posted February 13, 2007 Author Posted February 13, 2007 LOL, you know how I fixed it? At the header of my script, where I declare variables and such...I added this...arggg!!! now it is fine! GLOBAL $szTzKey
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