winreg

Alex Martelli aleaxit at yahoo.com
Mon Dec 11 22:52:46 CET 2000


"Scott Hathaway" <slhath at home.com.nospam> wrote in message
news:sh9Z5.6204$bw.481106 at news.flash.net...
> Hello Everyone,
>
> I was looking at the online documentation on the winreg module that allows
> editing of the windows registry.  I am too new to python to understand how
> to code it.  Can someone get me started in the right direction?
>
> I need to add a key and then add 5 values to that key.

With Python 2, for example:

import _winreg as w

parentKey = w.OpenKey(w.HKEY_CLASSES_ROOT,r'file\shell',0,w.KEY_WRITE)
newKey = w.CreateKey(parentKey,'SubkeyName')
w.SetValueEx(newKey,'AValueName1',0,w.REG_SZ,'Something here')
w.SetValueEx(newKey,'AValueName2',0,w.REG_SZ,'Something else')

will create a key 'file\shell\SubkeyName' (assuming 'file' and 'file\shell'
already exist!) under HKEY_CLASSES_ROOT, with no default (unnamed)
value, and two named values under it.


Alex






More information about the Python-list mailing list