Python COM Server with C++
John J. Lee
jjl at pobox.com
Fri Jan 16 20:42:06 CET 2004
andre.bernemann at gmx.de (Andre Bernemann) writes:
> I have written a Python COM Server with the help of Mark Hammond's
> Book Programming Python on Win32. I used the CreateObjects method in
> VB to access the COM Methods and all worked fine. Unfortunately, that
> is not what i really want. First I'd like to make the COM Server
> accessible from C++ and as a beside product I want to use early
I'd do this in ctypes, although its COM support is still quite new.
win32com (from win32all, aka Python for Windows Extensions, which is
what you're probably using ATM) has recently grown support for
implementing vtable interfaces (but not calling them, IIRC), but I
suspect one is less likely to get stuck when using ctypes, since
everything is pretty close to the way you'd do in in C (COM makes that
quite complicated, of course, but I think the ctypes COM support is
fairly 'thin' -- probably a good thing, IMHO -- but also elegant).
> binding within VB with the NEW operator. I've googled around alot, but
> I still have not the complete picture of what to do.
Take at look at win32/com/samples/server in the ctypes package -- an
example of implementing a dual interface. I haven't tried a dual
interface myself, but, as COM goes, it all looks very simple and
> So far I think I have to create an IDL file to describe the interface
> and compile it with the MIDL Compiler. There ist my first question.
> What do I have to create first, the IDL file or the Python COM Server?
IDL first. This is explained in the little comment at the top of the
> I'm a little bit confused about dispid's, the GUID's and naming
> conventions. Do i need to make use of the makepy Utility in any way?
I don't know how one implements vtable/dual interfaces in win32com.
> Do I have to modify the Python COM Server Source Code in any way or
> can I use it as it is? (I can post the code here on request)
More information about the Python-list