EnumKey vs EnumValue

P

Pykid

I'm having trouble getting any responses back from the following
snippet, where I am just trying to read some data from the Windows
Registry. I intend to do a little bit more with this but will work on
that later, but I think I can get more data back from EnumValue, I'd
like to see the differences between them. I am running Python 2.3 on
XP and can get a response from EnumKey, but EnumValue returns nothing
at all; the key listing even returns 0 keys when it prints out the
status. But EnumKey returns the right number and even prints out the
keys I expect, I copied some of this from the Cookbook and can't tell
what might be the problem.

Thanks for any help.

- M
-------------------------------------

from _winreg import *

findkey = raw_input("What key do you want to look for? ")

key = "SOFTWARE\\"+findkey
machine = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
regpath = OpenKey(machine,key)

print "Looking for",key

for i in range(25):
try:
regEndeca = EnumKey(regpath,i)
print regEndeca
except EnvironmentError:
print "There are", i,"keys under",key
break
print "That was using EnumKey."

for j in range(25):
try:
regstr,value,type = EnumValue(regpath,j)
print regstr,value,type
except EnvironmentError:
print "There are", j,"keys under",key
break
print "That was using EnumValue."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,160
Latest member
CollinStri
Top