Retrive unicode keys from the registry

Neil Hodgson nhodgson at bigpond.net.au
Fri Jan 16 21:31:38 CET 2004


Thomas Heller:

> def RegQueryValue(root, subkey):
>     if isinstance(subkey, unicode):
>         return _winreg.QueryValue(root, subkey.encode("mbcs"))
>     return _winreg.QueryValue(root, subkey)
>
> Does this look ok?

   It will fail for keys that can not be encoded in your current code page.
That will not often be a problem but if you want to be safe then access to
the wide version is needed.

   Neil





More information about the Python-list mailing list