rv...@free.fr wrote:

I'm trying to translate a VBA application to Python. I cannot change the COM Server as its works also with others programs. It seems I have a problem with win32com.client by passing an array of double to a COM method.

VBA allows to pass arrays to COM server byref on the first element of the array
...||

From typelib COM interface

|[id(0x00000007), helpstring("Méthode GetValues")] HRESULT GetValues([in, out] double* pValues); # pointer on array of double [id(0x00000008), helpstring("Méthode SetValues")] HRESULT SetValues([in] double* pValues);|

...

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.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to