Problems passing arrays into COM objects using win32com

Discussion in 'Python' started by mb3242, May 13, 2005.

  1. mb3242

    mb3242 Guest

    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:
    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/pipermail/pycom-dev/1998q4/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
     
    mb3242, May 13, 2005
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.