_winreg problem

Brad Tilley bradtilley at usa.net
Fri Oct 8 01:40:48 CEST 2004

Larry Bates wrote:
> It took me DAYS to find this on the Net.  The "trick" is you need
> extra parameters on your OpenKey call, otherwise you get your error.
> Try following, I think it will help.:
>     key = OpenKey(HKEY_LOCAL_MACHINE, x, 0, _winreg.KEY_SET_VALUE)
> Good Luck,
> Larry Bates

Thanks, besides using OpenKey() correctly, I found that the values did 
indeed have to be ints... here's a working function:

def log_limits():
     logs = ['Application', 'Security', 'System']
     vals = {'Retention':0, 'MaxSize':10223616, 'RestrictGuestAccess':1}
     for l in logs:
         x = r"SYSTEM\CurrentControlSet\Services\Eventlog\%s" % l
         key = OpenKey(HKEY_LOCAL_MACHINE, x, 0, KEY_SET_VALUE)
         for n,v in vals.iteritems():

More information about the Python-list mailing list