[python-win32] Accessing other interfaces of a Dispatch created COM object

Tim Roberts timr at probo.com
Thu Sep 11 01:33:50 CEST 2008


Alec Munro wrote:
> Thanks for the clarification Tim.
>
> My root problem is still the "Library not registered" issue. As far as
> how it was registered:
>
>  * I maintain a dll that defines a class that implements I1 and I2. I
> use regsvr to register this dll.
>  * I1 and I2 come from a third party, and in order for my dll to work
> properly, it has to implement them (actually I2 is optional).
>  * I don't know how I1 and I2 are registered. I do know that if I use
> the COM browser, I can go to Registered Type Libraries, find one with
> the typelibname that is associated with my CastTo created objects,
> which has "Type Library" underneath it, and underneath that are
> entries for I1, I2, several related interfaces, and a variety of
> coclasses. Like this:
>  - TypeLibName 1.0 TypeLibrary
>  -- IID: {00..00}
>  -- Type Library
>  --- I1 - Dispatch
>  --- I2 - Dispatch
>  --- IX - Dispatch
>  --- CX - CoClass
>
> I've just spent some time hunting through the registry to determine
> the differences between I1 and I2.
>
> Looking the gen_py files, they have the same package CLSID, and the
> same class coclass_clsid. But their class CLSIDs differ.
>   

Well, we may be getting confused about identifiers here.  The IID listed
below the typename is the type library UUID.  It identifies the type
library, which is just a collection of definitions.  Within the type
library, you have interfaces, and you have coclasses.  An interface also
has an IID, and that's the important IID to use when you query for an
interface.  A coclass is a concrete object that implements one or more
of the interfaces -- the "default" object for those interfaces, if you
like.  A coclass is identified by a CLSID.

In gen_py, the "CLSID = IID(...)" line at the top of the file should be
the type library UUID.  The "CLSID = IID(...)" line at the top of each
class is the IID for the interface being exposed by this coclass.  The
coclass_clsid is the model coclass that implements the interface.  If
you try to create an object of this type, PythonCom will essentially do
a CoCreateObject on the coclass_clsid, using the IID of the interface.

So, your two interface should have different CLSID lines at the top of
the class, and you should find those IIDs listed in
HKEY_CLASSES_ROOT\Interface.

> So I searched through the registry for those CLSIDs. They show up in
> the same places, once each under HKEY_CLASSES_ROOT and
> HKEY_LOCAL_MACHINE.

HKEY_CLASSES_ROOT is just a "symbolic link" shortcut to
HKEY_LOCAL_MACHINE\Software\Classes.  Everything in one will be in the
other.

No solution yet, but maybe this provides more background information.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list