My code (simplified):
Code:
import _winreg as winreg
SetRegistry(winreg.HKEY_LOCAL_MACHINE, key, values)
def SetRegistry(reg, key, values):
reghandle = winreg.ConnectRegistry(None, reg)
This works, but I would like to pass HKEY_LOCAL_MACHINE as a string because I want to make a backup of changed registry settings, but how do I pass this on to ConnectRegistry? This for example won't work for obvious reasons (changes in red):
Code:
import _winreg as winreg
SetRegistry('HKEY_LOCAL_MACHINE', key, values)
def SetRegistry(reg, key, values):
reghandle = winreg.ConnectRegistry(None, winreg.reg)
Unfortunately, I can't use __str__(), since it's just an int:
Code:
>>> import _winreg
>>> print _winreg.HKEY_LOCAL_MACHINE
2147483650
>>> type(_winreg.HKEY_LOCAL_MACHINE)
<type 'long'>
Probably missing something simple ... :-/