[python-win32] Bug - Passing byref an array to a com method interpreted as a single element

Tim Roberts timr at probo.com
Mon Jan 21 14:05:40 EST 2019


Tim Roberts wrote:
> rvc69 at free.fr wrote:
>>
>> It seems win32client do not interpret correctly the type expected by 
>> the COM server, here float() instead of pointer on an array of float.
>>
>
> That statement is not accurate.  The fault is not in win32client. The 
> root of the problem is that the function definition in your type 
> library is not COM-compliant.  There are rules that need to be 
> followed in order for a COM interface to work seamlessly across 
> languages, and you have violated those rules.  The proper way to pass 
> an array is to use a SAFEARRAY. Your definition, for example, cannot 
> possibly work in an out-of-process server, because there is no way for 
> the marashaling code to know how much data to send across.  The 
> GetValues case is doubly hopeless.  How can the server know how large 
> the buffer is?  How can the client know how much data will be 
> returned?  You are simply not allowed in COM to have that be assumed.
>
> Win32client is quite correct in interpreting your definition as it 
> does.  The fact that it works in VBA is an lucky accident.  If you 
> want this to work reliably, you need to change the interface.

Having said all that, you may be able to do what you need with the 
"comtypes" module, which allows lower-level access to COM interfaces.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3980 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-win32/attachments/20190121/b9966212/attachment.bin>


More information about the python-win32 mailing list