Unable to create com object - need help

Thomas Heller theller at python.net
Wed Apr 14 07:57:05 EDT 2004


"Roman Yakovenko" <roman.yakovenko at actimize.com> writes:

> 	Hi. I need some help. 
> Here is my situation. It is a little bit difficult to explain and/or understand.
> I'd like to use msdia71.dll. This dll gives you access to program database files
> created during a build. I register this dll. This is pure com dll. 
> This dll contains 3 top classes. I'd like to create one of them - DiaSource. 
> This class implements IDiaDataSource interface. This fact I can see in dia2.idl. 
>
>  importlib("stdole2.tlb");
>     [
>         uuid(e60afbee-502d-46ae-858f-8272a09bd707),
>         helpstring("DiaSource Class")
>     ]
>     coclass DiaSource
>     {
>         [default] interface IDiaDataSource;
>     };
>
> after using makepy I get 
>
> class DiaSource(CoClassBaseClass): # A CoClass
> 	# DiaSource Class
> 	CLSID = IID('{E60AFBEE-502D-46AE-858F-8272A09BD707}')
> 	coclass_sources = [
> 	]
> 	coclass_interfaces = [
> 	]
> If I understand right DiaSource doesn't implements IDiaDataSource interface at all. 
> May be this is a bug, may be I don't understand something. Clarifying this point will be great.

I think this has to do with the fact that with pywin32 you cannot access
arbitrary com interfaces - only interfaces that either have been wrapped
in pythoncom.dll or that derive from IDispatch.  The DIA interfaces all
derive from IUnknown, so it seems you cannot call them.

There is ongoing work in pywin32 named 'universal' or something like
that, but I don't know how far it is.

Another possibility is to use ctypes com layer, it has a tool somewhat
similar to makepy - it's called readtlb.py, and creates python wrappers
for com interfaces.  ctypes.com has some samples demonstrating all this.

HTH,

Thomas





More information about the Python-list mailing list