Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote:

> > but simpler still and more reliable to just call QueryValueEx.
> 
> I find it more complicated.

I have now (after long studying docs and examples)::

def get_winreg(key,subkey):
  try:
    rkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,key,0,winreg.KEY_READ)
    rvalue,rtype = winreg.QueryValueEx(rkey,subkey)
    winreg.CloseKey(rkey)
  except WindowsError:
    rvalue,rtype = None,None
  return rvalue


def set_winreg(key,subkey,value):
  winreg.CreateKey(winreg.HKEY_CURRENT_USER,key)
  rkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,key,0,winreg.KEY_WRITE)
  winreg.SetValueEx(rkey,subkey,0,winreg.REG_SZ,value)
  winreg.CloseKey(rkey)

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum IZUS/TIK         E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-68565868
Allmandring 30a                Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to