The Windows Registry is a database that contains program and system information and settings. Often it can be useful to access the Registry (to read from it or write to it) via a script. The winreg module makes this easy to do in Python.
The following example queries a particular key in the Registry and outputs all the subkeys for that key:
import _winreg explorer = _winreg.OpenKey(
# list values owned by this registry key i = 0
name, value, type = _winreg.EnumValue(explorer, i) print repr(name), i += 1
The following is the output for this program:
'ShellState' 'CleanShutdown' 'Browse For Folder Width' 'Browse For Folder Height ' 'link' 'Logon User Name'
Was this article helpful?