[python-win32] win32com support for pointer in-parameters
Jeremy Kloth
jeremy.kloth at gmail.com
Tue May 28 20:26:47 CEST 2013
I have been struggling with getting pointer parameters to work with the COM
interface for VirtualBox. In particular, the IFramebuffer interface. I
cannot seem to get the following to give the expected results:
interface IFramebuffer : IDispatch
{
// snipped to just the interesting definition
HRESULT RequestResize (
[in] ULONG aScreenId,
[in] ULONG aPixelFormat,
[in] BYTE * aVRAM,
[in] ULONG aBitsPerPixel,
[in] ULONG aBytesPerLine,
[in] ULONG aWidth,
[in] ULONG aHeight,
[out, retval] BOOL * aFinished
);
};
The type for aVRAM ends up being (correctly) VT_BYREF | VT_UI1.
Unfortunately PyIDispatch (incorrectly) converts the parameter to just
VT_UI1. The offending code path is: PyGatewayBase::Invoke() ->
invoke_setup() -> PyCom_PyObjectFromVariant() -> VariantCopyInd().
My not so informed understanding is that pythoncom considers all VT_BYREF
parameters as out-type parameters whereas, in this case at least, it is not
always such. Indeed, in this case, the aVRAM parameter needs to be the
*address* not the *value* for an object to implement IFramebuffer properly.
Note that the object implementing IFramebuffer is passed as argument to
another function much the same way as event listeners.
I believe the fix involves PyIDispatch somehow using the type information
to determine which parameters are not out-type and then to not dereference
those.
Any direction with this is greatly appreciated.
Jeremy Kloth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20130528/6bdcbf62/attachment.html>
More information about the python-win32
mailing list