Regarding Value Types: http://docs.python.org/2/library/_winreg.html#value-types
How do I query _winreg.REG_BINARY
for 'REG_BINARY'
?
I can do it manually with:
import _winreg
reg_type_str = {
_winreg.REG_BINARY: 'REG_BINARY',
_winreg.REG_DWORD: 'REG_DWORD',
_winreg.REG_DWORD_LITTLE_ENDIAN: 'REG_DWORD_LITTLE_ENDIAN',
_winreg.REG_DWORD_BIG_ENDIAN: 'REG_DWORD_BIG_ENDIAN',
_winreg.REG_EXPAND_SZ: 'REG_EXPAND_SZ',
_winreg.REG_LINK: 'REG_LINK',
_winreg.REG_MULTI_SZ: 'REG_MULTI_SZ',
_winreg.REG_NONE: 'REG_NONE',
_winreg.REG_RESOURCE_LIST: 'REG_RESOURCE_LIST',
_winreg.REG_FULL_RESOURCE_DESCRIPTOR: 'REG_FULL_RESOURCE_DESCRIPTOR',
_winreg.REG_RESOURCE_REQUIREMENTS_LIST: 'REG_RESOURCE_REQUIREMENTS_LIST',
_winreg.REG_SZ: 'REG_SZ',
}
reg_type_str.get(_winreg.REG_SZ)
Surely there's a better way?
Example Query:
reg_data, reg_type = _winreg.QueryValueEx(key, reg_value)
log.debug("Query: %s [%d:%s]" % (reg_data, reg_type, reg_type_str.get(reg_type)))
I'm thinking I should be able to do something like this:
>>> for k, v in _winreg.__dict__:
... if v == _winreg.REG_SZ:
... print k
Traceback (most recent call last):
File "<pyshell#468>", line 1, in <module>
for k, v in _winreg.__dict__:
ValueError: too many values to unpack
Of course, that doesn't work, but even if it did this method would cause issues when used with _winreg:
>>> for v in _winreg.__dict__.itervalues():
... if v == _winreg.REG_SZ:
... print v
1
1
1
1
1
1
I've come to the conclusion that I need to do it using the manual method supplied in the original question.
The only way around this is if the _winreg developers supply a function for us.