It is possible with some low-level changes to the generated GetPacket
.
Source: [comtypes-users] Right way to call a method with a pointer to array?
# change GetPacket so the second argument is in, not out
packet = (c_ubyte * size)()
data.GetPacket(guid, size, packet)
However, note that typelibs don't contain information about size_is
, length_is
and a few other things. This means that the generic typelib marshaller proxies and stubs, used across apartment and process boundaries, will not look into lSize
to determine how many elements to serialize from pData
, it'll always (try to) serialize a single pointed item.
In other words, that kind of code, whether C++ or Python, will only work in the same apartment.