Sign in to follow this  
Followers 0
dufran3

Searching Registy and adding keys to array

5 posts in this topic

#1 ·  Posted (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 by dufran3

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

J-E-L-L-O!!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0