[python-win32] COM array problem
Mark Hammond
skippy.hammond at gmail.com
Wed Jul 29 06:49:00 CEST 2009
On 29/07/2009 4:29 AM, Reinier Heeres wrote:
> Hi everybody,
>
> I have a problem with a function of a COM object that is supposed to
> return an array of data. The function prototype generated by
> win32com's EnsureDispatch is as follows:
>
> def GetFrame(self, frame=defaultNamedNotOptArg,
> FrameVariant=defaultNamedNotOptArg):
> """Get Frame Data"""
> return self._ApplyTypes_(10, 1, (24, 0), ((2, 1), (16396, 3)),
This is declaring the function has a return type of 24 (VT_VOID), and
takes 2 params - one in param of type 2 (VT_I2) and the other a 'retval'
param of 16396 == 0x400c == VT_BYREF | VT_VARIANT.
> u'GetFrame', None,frame
> , FrameVariant)
>
> which from my understanding means that the type which gives the
> problem is VT_R4 | VT_BSTR | VT_BYREF. (I've seen problems with byref
> return values before on the mailing list archives, but I don't know if
> they apply here).
>
> The error is slightly undescriptive (snipped a part):
>
> 454 def _ApplyTypes_(self, dispid, wFlags, retType,
> argTypes, user, resultCLSID, *args):
> 455 return self._get_good_object_(
> --> 456 self._oleobj_.InvokeTypes(dispid, 0,
> wFlags, retType, argTypes, *args),
> 457 user, resultCLSID)
> 458
>
> com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
> 0, -2147024809), None)
>
> I don't exactly understand where the problem is: is it before the call
> to the actual COM function while creating an empty object, in the COM
> call, or after the call casting the result? Any ideas on how to fix
> this would be welcome; I could try to make patches for win32com.
The problem is the COM object returning DISP_E_EXCEPTION with an scode
value of -2147024809 - which in turn is E_INVALIDARG.
> BTW: I can get it to work with comtypes (but that gives problems on
> some other calls), so in principle it should be possible.
> Unfortunately I don't have access to the source of the COM object I'm
> using.
I suspect pythoncom is passing the variants described above - but maybe
the variant isn't initialized as expected or something. Do you know
exactly how the variants passed by ctypes were laid out?
Cheers,
Mark
More information about the python-win32
mailing list