win32 registry access

Hauke Fath hf at tangro.de
Tue Nov 21 10:23:42 EST 2000


Hi,

while porting a perl script to python, I am experiencing problems with
registry access.

The function

def get_local_reg_key(rpath):
    root_key = _winreg.HKEY_LOCAL_MACHINE
    key = _winreg.OpenKey(root_key, rpath)
    val = _winreg.QueryValue(key)
    _winreg.CloseKey(key)
    return val

, fed with a valid registry path ("works in perl"), gives me

[...]

  File "./RetroEventHandler.py", line 180, in init
    db2_home = get_local_reg_key("SOFTWARE\\IBM\\DB2\\GLOBAL_PROFILE\\DB2PATH")
  File "./RetroEventHandler.py", line 164, in get_local_reg_key
    key = _winreg.OpenKey(root_key, rpath)
WindowsError: [Errno 2] The system cannot find the file specified

Searching the usual suspects aka web sites gave nothing. Any ideas?

I should add that my python knowledge is no older than a few days.
;-)

        hauke



More information about the Python-list mailing list