I go back to my original sample with a little tweak...

Code:

$i = 0
Do $KeyName = EnumKey("HKEY_CURRENT_USER\Software\",$i)
If Not @ERROR
"Name found: $KeyName" ?
$i=$i+1
EndIf
Until @ERROR


...or, if you'd rather...
Code:

$i = 0
Do $KeyName = EnumKey("HKEY_CURRENT_USER\Software\",$i)
If $KeyName
"Name found: $KeyName" ?
$i=$i+1
EndIf
Until Not $KeyName