Menu

#79 Exception raised accessing REG_EXPAND_SZ type in registry

closed-fixed
nobody
com (105)
5
2004-04-22
2004-01-29
No

I ran into two problems using Makepy and the COM
Browser both caused by the same type library registry
entry. This entry was of the type REG_EXPAND_SZ
instead of the usual REG_SZ.

When running the COM Browser and expanding the
registered type libraries, I woud get the following
exception:
File "win32com\client\combrowse.py", line 498, in
GetSubList
name = win32api.RegQueryValue(subKey, versionStr)
pywintypes.error: (13, 'RegQueryValue', 'The data is
invalid.')
win32ui: Exception in OnNotify() handler

When running Makepy, I got the following:
File "win32com\client\selecttlb.py", line 122, in
EnumTlbs
spec.ver_desc = tlbdesc + " (" + version + ")"
TypeError: unsupported operand types for +: 'NoneType'
and 'str'

In both cases I traced the source of the error to a call
to win32api.RegQueryValue(). From what I can tell, this
function does not handle the REG_EXPAND_SZ type.
The documentation for this function, that I found on
ActiveState, says that this function should be avoided,
and win32api.RegQueryValueEx() should be used instead.

So, in combrowse.py I replaced
name = win32api.RegQueryValue(subKey, versionStr)
with:
subSubKey = win32api.RegOpenKey(subKey,
versionStr)
name = win32api.RegQueryValueEx(subSubKey, '')[0]

And in selecttlp.py, EnumKeys() I replaced
val = win32api.RegQueryValue(root, item)
to:
subKey = win32api.RegOpenKey(root, item)
val = win32api.RegQueryValueEx(subKey, '')[0]

This seems to work, but I am completely new to this
API, so I make no guarantees.

It looks like there are many other places that use
RegQueryValue(), so they may need to be changed
aswell.

I am running Python 2.2.3, with win32all build 162, on
windows XP. The registry entry that caused the
problem was for the LDMView ActiveX Control module.

Discussion

  • Mark Hammond

    Mark Hammond - 2004-04-22

    Logged In: YES
    user_id=14198

    Thanks! The fix I came up with is a little different, but I
    was able to reproduce the problem, so I'm fairly sure it is
    fixed.

    Checking in selecttlb.py;
    new revision: 1.7; previous revision: 1.6
    Checking in combrowse.py;
    new revision: 1.6; previous revision: 1.5

     
  • Mark Hammond

    Mark Hammond - 2004-04-22
    • status: open --> closed-fixed