469,354 Members | 2,035 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,354 developers. It's quick & easy.

Problems passing arrays into COM objects using win32com

Hello, I'm trying to use win32com to call a method in a COM object.
I'm having a problem with Python choosing the wrong type when wrapping
up lists into VARIANTs.

The function I'm trying to call in C++ looks like this:
HRESULT write([in] VARIANT * len, [in] VARIANT * saData, [out] VARIANT
* result);
Where saData contains a SafeArray of bytes and len is its length. The
function returns any error information in result.

I'm using Python 2.4.1 with pywin32 build 204. I access the COM object
using:
import win32com.client
o= win32com.client.Dispatch('foo.fooAPI.1')
o.write(2, [3,4])


If I run the COM object in the debugger, I can see what Python has
passed in. len.vt = 0x0003; an integer as expected. But saData.vt =
0x200C, an array of VARIANTs. It should be an array of ints, but it's
not.

I've found a 1998 posting from the pythonCOM dev mailing list that
describes a similar problem, but the solution doesn't work for me:
http://mailman.pythonpros.com/piperm...q4/000006.html
Mark Hammond recommends using makepy to generate the type info ahead of
time, and using win32com.client.Dispatch("...") instead of
win32com.client.dynamic.Dispatch("..."). At the time of that posting,
statically generated objects would map into arrays of ints (as
expected), while dynamically generated objects wouldn't.

This sounds reasonable, but I'm already doing what he recommends. I've
looked around for other documentation, but I haven't had any luck. The
documentation (not surprisingly) hasn't kept up with changes over the
years.

thanks,

Mark Brighton

Jul 19 '05 #1
0 1694

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by harry | last post: by
11 posts views Thread by John Pass | last post: by
reply views Thread by guilligan.geo | last post: by
2 posts views Thread by Mike | last post: by
17 posts views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.