[python-win32] Python and IUnknown-based COM objects

Tim Golden mail at timgolden.me.uk
Mon Jul 7 18:14:08 CEST 2008


Kirk Fertitta wrote:
> I am trying to use a COM component that does not support the IDispatch 
> interface.  It has only early-bound IUnknown derived interfaces in it.  
> The folks at ActiveState directed me to this list for some assistance.  
> It seems from some of the documentation I’ve come across that Python can 
> make early-bound function calls, but it seems that all of the creation 
> mechanisms perform a QueryInterface for IDispatch (which, of course, 
> will always fail for our COM components).  Does anyone have any idea on 
> if/how Python can be used with non-IDispatch COM components?  Any advice 
> is very much appreciated.

The short answer is: you want comtypes.
I recommend getting the svn trunk

http://starship.python.net/crew/theller/comtypes/

The longer answer is that there *is* support for non-IDispatch
interfaces in pywin32, but it's more-or-less the raison d'etre for
comtypes (whose principal architect Thomas Heller is still away
on holiday, I think), while it's one thing among many in pywin32
which is notoriously underdocumented and more complex in any 
case.

TJG


More information about the python-win32 mailing list