ivan_pozdeev ivan_pozdeev - 1 year ago 118
Python Question

IZoneIdentifier interface is missing from registry despite being documented in MSDN

I'm trying to implement Manipulating the zone identifier to specify where a file was download from – The Old New Thing - MSDN blogs in Python.
This doesn't really matter though, I only use Python code to demonstrate the symptoms (thus no tag). Scroll down to a horizontal line and a header for the root problem and question if you wish.



pywintypes.IID('{0968e258-16c7-4dba-aa86-462dd61e31a3}'), #CLSID_PersistentZoneIdentifier
pywintypes.IID('{cd45f185-1b21-48e2-967b-ead743a8914e}')) #IID_IZoneIdentifier

I get an error:

TypeError: There is no interface object registered that supports this IID

(No stacktrace as this is an extension function)

If I replace the
IID with
, it works, but a
with the right IID fails with the same error.

Indeed, in
, I see nothing like
but do see an

The Problem

Having disassembled
, I see that it indeed implements the interface, but doesn't register it in its
. Searching further, I see that
is being registered by
- but not

MSDN documents this interface to be available since IE6. But it's not there in either IE7 or IE8. Since this is XP (and with all the updates allegedly), I've nothing else to try.

Likewise, the interface is present in Windows SDK 7.0 in the
file mentioned in the MSDN article.

The questions are:

  • Was this interface silently dropped in favour of something else without MSDN reflecting that or something? Alternatively, is this a known issue? Is it available in later versions of IE?

  • What components do
    pertain to (so I can try (un)installing updates for them)?

Answer Source

There's nothing wrong with IZoneIdentifier. The original C++ program runs just fine. As @IgorTandetnik pointed out, not every interface an object implements is going to be registered in the registry, only those that support marshalling.

The error comes from pythoncom itself (a hint is that it's a ValueError, not pythoncom.com_error, and the error message is always in English rather than the system's UI language).

The cause is that pythoncom indeed requires IDispatch support by the interface - or it wouldn't be able to deduce how to work with the interface's functions and values they accept/return.

The only exception is a number of IUnknown-based interfaces support for which is compiled in (IPersistFile is one of them; the full list is in pythoncom.InterfaceNames, apparently).

Support for other IUnknown-based interfaces can be added with a "pythoncom extension" module. Some (very scarce) documentation on them can be found in pywin32 docs in the Python and COM - Implementation Details article.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download