[python-win32] PythonWin COM Client Problem Accessing Methods in C++ MFC COM Server

Steve Johnston stevej at photonengr.com
Wed Oct 27 18:50:35 CEST 2010


First, a little background to help explain the problem.  I have a C++ MFC
application configured as an Automation COM server.  It has a dual interface
defined in a type library embedded as a resource in the executable.  The
dual interface has been been implemented according to the Microsoft help
article "TN065: Dual-Interface Support for OLE Automation Servers".  The
application also has dispinterface which implements only a small subset of
the properties and methods contained in the dual interface.  The BASIC
scripts in Excel can successfully invoke methods in the dual interface as
long as I "Dim myobject As mydualinterface" instead of "Dim myobject As
Object".
OK, now here is the problem.  Python seems to be able to invoke the
properties and methods in the dispinterface, but is completely unable to
invoke anything in the dual interface.  I have run MakePy and it seems to
generate the proper py file.  PythonWin definitely "understands" the type
library and all of its methods and properties.  As I type a method name in
the editor, the entire list of methods in the dual interface pops up in the
help list.  Also, the type library defines a number of structures that I can
successfully access and use as Python records.
Here is an example from the PythonWin Interactive Window.
PythonWin 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for
further copyright information.
>>> import win32com.client
>>> app = win32com.client.Dispatch("FRED.Application")  #### Success!
>>> app.Visible = True   #### Success because "Visible" is a property in the
dispinterface.
>>> y = app.Acos(0.5)   #### Interactive editor lists this method in the
popup window as I type, but Invoke fails during execution!
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File
"C:\Python26\lib\site-packages\win32com\gen_py\D604334A-6198-4BEC-9AE9-6038B
7352C9Ax0x2x24\IDualFREDApp.py", line 33, in Acos
    return self._oleobj_.InvokeTypes(20, LCID, 1, (5, 0), ((5, 1),),x
com_error: (-2147352573, 'Member not found.', None, None)
>>> 

I see the same error if I attempt to Invoke any method in the dual
interface.

Is there anyone who can offer some insight into the problem?  Any thoughts
would be greatly appreciated!

Regards,
SCJ

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20101027/2d19e7d2/attachment.html>


More information about the python-win32 mailing list