Calum McLean schrieb: > Hi, > > I have a method from some 3rd party COM with the following IDL description. > > [id(6), helpstring("method GetPos")] HRESULT GetPos([out, size_is(Size)] > double* Positions, [in] long Size, [out, retval] long * pReturnedSize); > > I can't seem to work out what syntax I should use to return the 'Positions' > data. > > The kind of thing I have tried is as follows:- > > (pos,rs) = m.GetPos(3) > > rs is returned correctly. > pos is just a single element.
comtypes cannot handle this signature automatically for various reasons. At least one reason is that the 'size_is(Size)' attribute is present in the IDL but not in the type library that comtypes uses to generate the wrapper code. You must implement the GetPos() method yourself in the generated interface class. It should call the low-level, normally invisible, automatically generated _GetPos method with arguments that you create yourself. class ...: def GetPos(self, size): returned_size = c_long() positions = (c_double * size)() self._GetPos(byref(positions), size, byref(returned_size)) return positions[:returned_size.value] Thomas ------------------------------------------------------------------------------ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users