_winreg problem
Brad Tilley
bradtilley at usa.net
Thu Oct 7 19:40:48 EDT 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():
SetValueEx(key,n,0,REG_DWORD,v)
CloseKey(key)
More information about the Python-list
mailing list