Jump to content

RegEnumVal en RegEnumKey unexpected results


Recommended Posts

When I try to use the Functions RegEnumKey and RegEnumVal I get unexpected results:

I have made this sample code:

ConsoleWrite('RegEnumVal' & @LF)
;
For $i = 1 To 3
    $var = RegEnumVal("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\", $i)
    If @error <> 0 Then
        ConsoleWrite("@error: " & @error & @LF)
        
        ExitLoop
    EndIf
    ConsoleWrite("SubVal #" & $i & " under HKLM\CurrentControlSet\Control\Session Manager\Environment: " & $var & @LF)
Next
;
ConsoleWrite('RegEnumKey' & @LF)
;
For $i = 1 To 3
    $var = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\", $i)
    If @error <> 0 Then
        ConsoleWrite("@error: " & @error & @LF)
        
        ExitLoop
    EndIf
    ConsoleWrite("SubKey #" & $i & " under HKLM\CurrentControlSet\Control\Session Manager\Environment: " & $var & @LF)
Next

and I get the following results:

Watch the version (3.2.12.0)

>Running:(3.2.12.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\ComicHtmlMenuBuilderDevelopment\remove before shipping\tst.au3"  
RegEnumVal
SubVal #1 under HKLM\CurrentControlSet\Control\Session Manager\Environment: CLASSPATH
SubVal #2 under HKLM\CurrentControlSet\Control\Session Manager\Environment: ComSpec
SubVal #3 under HKLM\CurrentControlSet\Control\Session Manager\Environment: FP_NO_HOST_CHECK
RegEnumKey
@error: -1

Please help me out

As far I can see from RegEnumVal I get keys and from RegEnumKey I get an error

Link to comment
Share on other sites

  • Developers

I don't have any keys in that Registry tree, only fields and values.

what is it you expected to see ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Like this?

ConsoleWrite('RegEnumVal' & @LF)
;
For $i = 1 To 3
    $var = RegEnumVal("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\", $i)
    If @error <> 0 Then
        ConsoleWrite("@error: " & @error & @LF)
        ExitLoop
    EndIf
    $fieldval = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment",$var)
    ConsoleWrite("SubVal #" & $i & " under HKLM\CurrentControlSet\Control\Session Manager\Environment: " & $var & " : " & $fieldval & @LF)
Next

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Like this?

ConsoleWrite('RegEnumVal' & @LF)
;
For $i = 1 To 3
    $var = RegEnumVal("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\", $i)
    If @error <> 0 Then
        ConsoleWrite("@error: " & @error & @LF)
        ExitLoop
    EndIf
    $fieldval = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment",$var)
    ConsoleWrite("SubVal #" & $i & " under HKLM\CurrentControlSet\Control\Session Manager\Environment: " & $var & " : " & $fieldval & @LF)
Next

:(

Absolutely right. Thanks. :)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...