[python-win32] Re: Can we add 'native COM support' to a 3rd party DLL/OLB

Thomas Heller theller at python.net
Fri May 23 18:25:14 EDT 2003


[cc to ctypes-users list]

> > I have not really followed the discussion, but ctypes has support
> > for vtable based interfaces. I'm currently writing some docs, you may
> > want to check it out:
> > 
> > http://starship.python.net/crew/theller/ctypes/
> > http://starship.python.net/crew/theller/ctypes/com.html
> > http://starship.python.net/crew/theller/ctypes/sum_sample.html

> 
> A quick read of the com.html and sum_sample.html is very interesting.
> I'm currently having trouble sending events from pythoncom servers to VB
> clients. Do you think the ctypes module will work better for me in this
> regard. The only reference to events that I found in your docs was the
> ctypes.com.connectionpoints module, which you say is for receiving
> events.

There's a sample which uses Internet Explorer with automation, and
receives events over a connectionpoint.  This is not yet in the docs.

> 
> Actually my problem involves a design that I'm sure is not uncommon, and
> I expect either PythonCOM or ctypes can solve it, but I've just not
> figured out how. If you have any advice, I'd love to hear it. The
> problem is I have a VB client (so single threaded apartment), and some
> multithreaded python code that does a bunch of calculations, some of
> which are time consuming. I want to glue the two together with COM such
> that:
> - VB CoCreates a python COM object which it calls to start the
> calculation
> - python creates a second thread to do the calculation, so the
> 'StartCalcultion' is non-blocking.
> - python thread signals the VB when it's finished (I've tried a callback
> VB COM object, which sort of works, and then crashes after # calls, but
> would probably prefer to use windows messages or some kind of events).

>From what I understand this should be possible even with win32com, maybe
Mark Hammond can comment on that.

The ctypes COM stuff is pretty new and work in progress, currently it's
not even possible to create inproc servers, but I'm working on that.

Thomas




More information about the Python-win32 mailing list