[python-win32] win32com calling C++ COM interface

Shad Muegge shad.muegge at gmail.com
Wed Oct 19 22:42:57 CEST 2005


Sorry, the interface is expecting a safearray of 4-byte integers, instead
it's getting a safearray of 1-byte integers.

On 10/19/05, bob <bgailer at alum.rpi.edu> wrote:
>
> At 01:22 PM 10/19/2005, Shad Muegge wrote:
> >Hi,
> >
> >I've just started looking at Python. I am trying to resolve an issue a
> >user is having trying to access the COM interface in our application from
> >Python.
> >
> >C++ code:
> >
> >STDMETHODIMP
> >CMyClass::Read(
> > const int x,
> > VARIANT *indexlist, // IN: "safe" array of 4-byte integers
> > VARIANT *results)
> >
> >
> >Python code:
> >
> > def read(self, x, addr):
> > try:
> > addr = buffer(array.array('L', addr))
> > data = self.__Api.Read(x, addr)
> >...
> >
> >x.read(0, 0x12345678)
> >
> >The variant that shows up on the C++ code is a safearray of 1-byte
> >integers with 4 elements: 12, 34, 56, 78.
> >
> >The API treats them each as individual "addresses"...
> >
> >Here's the COM definition from the .py file.
> >
> > def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg,
> > results=pythoncom.Missing):
> > """method Read"""
> > return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396,
> > 2)), 'Read', None,x
> > , indexlist, results)
> >
> Since I don't know the C++ side of COM I probably can't help. And perhaps
> it is for that reason that I don't even know what the user's issue is. If
> it is obvious to the cognoscenti, fine. For my sake could you elaborate.
> What is the "issue"?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20051019/a1f8d3e9/attachment.html


More information about the Python-win32 mailing list