Retrive unicode keys from the registry

Thomas Heller theller at python.net
Fri Jan 16 11:51:08 EST 2004


First I was astonished to see that _winreg.QueryValue doesn't accept
unicode key names, then I came up with this pattern:

def RegQueryValue(root, subkey):
    if isinstance(subkey, unicode):
        return _winreg.QueryValue(root, subkey.encode("mbcs"))
    return _winreg.QueryValue(root, subkey)

Does this look ok?

Thomas



More information about the Python-list mailing list