Sign in to follow this  
Followers 0
tazdev

Registry Sub Keys

5 posts in this topic

Is there a way to return the sub key folders under a certain registry key? I am trying to get a routine that will let me know what printers are connected for the current user on the PC.

HKCU\Printers\Connections -> Folders under this one

They are not the same each time and they only show the Network printers which is all I am interested in anyway. Any ideas? I am hoping it can be done with AutoIT's own functions like RegRead but I can't see how.

Share this post


Link to post
Share on other sites



Is there a way to return the sub key folders under a certain registry key? I am trying to get a routine that will let me know what printers are connected for the current user on the PC.

HKCU\Printers\Connections -> Folders under this one

They are not the same each time and they only show the Network printers which is all I am interested in anyway. Any ideas? I am hoping it can be done with AutoIT's own functions like RegRead but I can't see how.

<{POST_SNAPBACK}>

hi tazdev,

I am new to this too, but I needed to do a similar thing finding the JDk/JRE keys.

I basically put the info in two arrays so I could display key and path info

This code basically looks under a spcified key for a subkey (s) if one or more are there, it will read the values of the subkeys into an array, then I can later sort throug h the array to get what i need ...If anyone knows a better way to do this, i am open :lmao:

Hope this helps you get started

Dim $JDK[1]
Dim $JDKpath[1]
Dim $JCount= 1
Do 
    $JDKkey= RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit",$JCount)
    If not $JDKkey = "" Then
    $JDKloc= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"&"\" & $JDKkey,"JavaHome")
        redim $JDK[$JCount]
        redim $JDKpath[$JCount]
        $JDK[$JCount-1]=$JDKkey
        $JDKpath[$JCount-1]=$JDKloc
        $JCount = $JCount +1
    Else 
        $JDKkey=""
    Endif
until $JDKkey= ""
$jdmsg=""

For $i = 0 to ubound ($JDK)-1
    $jdmsg= $JDK[$i]& @tab & @tab & $JDKPath[$i] & @LF
    if $jdmsg="" then
        $jdmsg = "There are no JDK's installed and registered on this machine..."
    EndIF
next

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Oh

My

God

That was too easy. LOL. Now just need to get it to cycle through all of them with a while statement or something and WHOOHOOO. Thanks Larry!!!

DOH! While I wrote the above There was another post using a Do statement. Sweeeet! Thanks debstep!

Edited by tazdev

Share this post


Link to post
Share on other sites

Another little example: (modify it as such you need it.)

$sSKeys= _EnumSubKeys( "HKCU\Printers\Connections" )
MsgBox(0, "",  $sSKeys[1])

Func _EnumSubKeys( $sKey )
    Local $nInstance, $sData
    $nInstance = 1
    While 1
        $sData = $sData & RegEnumKey($sKey, $nInstance) & "|"
        If @error = 1 Then
            SetError(1)
            Return -1
        EndIf
        If @error = -1 Then ExitLoop
        $nInstance = $nInstance + 1
    WEnd
    Return StringSplit($sData, '|')
EndFunc

Share this post


Link to post
Share on other sites

That only returned one which is nice if that is all they have but I need to check more of them so I have:

$printercount = 1
Do
    $var = RegEnumKey("HKEY_CURRENT_USER\Printers\Connections", $printercount)
    MsgBox(4096, "Printer connection:","Connection number " & $printercount & ":" & $var)
    $printercount = $printercount + 1
Until $var = ""

This returns all of the printers under that key plus a blank. Which actually works well since I am going to add this to a text file so the extra blank is a nice spacer. I will also change the ,, to \\ eventually. Since I and 3 other people will only see it then it is no big deal. MUHAHAHAHAHAHA

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