Re: Calling a method with SAFEARRAY parameter

Thomas Geppert <[email protected]> Sat, 28 Sep 2024 09:35:57 +0200
Newsgroups gmane.comp.python.windows
Organization digitX GbR
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============6727823369814206808==
Content-Type: multipart/alternative;
 boundary="------------u3LoGaBF1b0GW9kkQ5bWjImW"
Content-Language: en-GB
Content-Transfer-Encoding: 8bit

This is a multi-part message in MIME format.
--------------u3LoGaBF1b0GW9kkQ5bWjImW
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

You can simply pass a string and two empty lists like:

titles, positions = GetTableInfo("TABLENAME", [], [])


Am 25.09.2024 um 13:41 schrieb Alessandro Fiorino:
>
> I have to call a method of a COM Object which is defined as
> GetTableInfo ([in] BSTR bstrTableName,[in, out] 
> SAFEARRAY(BSTR)*bstrColumnTitles,[in, out] SAFEARRAY(long)*lColumnPos)
>
> I tried with
>             columnTitles = VARIANT(pythoncom.VT_ARRAY | 
> pythoncom.VT_BSTR, [None])
>             columnPos = VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_I4, 
> [None])
>             object.GetTableInfo("TABLENAME", columnTitles, columnPos)
> and with
>             columnTitles = VARIANT(pythoncom.VT_ARRAY | 
> pythoncom.VT_BSTR, [""])
>             columnPos = VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_I4, [0])
>             object.GetTableInfo("TABLENAME", columnTitles, columnPos)
>
> but I get an error:
> Object ot type VARIANT has no len()
>
> What I am doing wrong ?
>
> Thanks in advance.
>
>
> _______________________________________________
> python-win32 mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-win32
--------------u3LoGaBF1b0GW9kkQ5bWjImW
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>You can simply pass a string and two empty lists like: </p>
    <div class="moz-forward-container">
      <p>titles, positions = GetTableInfo("TABLENAME", [], [])</p>
      <p><br>
      </p>
      <div class="moz-cite-prefix">Am 25.09.2024 um 13:41 schrieb
        Alessandro Fiorino:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAAmYX6zK=xbBG_aNL+S86Hiv4Y8r0+P0s_YZB1X+UT1GwBVgyQ@mail.gmail.com">
        <meta http-equiv="content-type"
          content="text/html; charset=UTF-8">
        <div dir="ltr">
          <div class="gmail-contents">
            <p> </p>
            I have to call a method of a COM Object which is defined as</div>
          <div class="gmail-contents">GetTableInfo ([in] BSTR
            bstrTableName,[in, out]
            SAFEARRAY(BSTR)*bstrColumnTitles,[in, out]
            SAFEARRAY(long)*lColumnPos)</div>
          <div class="gmail-contents"><br>
          </div>
          <div class="gmail-contents">I tried with</div>
                      columnTitles = VARIANT(pythoncom.VT_ARRAY |
          pythoncom.VT_BSTR, [None])<br>
                      columnPos = VARIANT(pythoncom.VT_ARRAY |
          pythoncom.VT_I4, [None])<br>
                      object.GetTableInfo("TABLENAME", columnTitles,
          columnPos)
          <div>and with</div>
          <div>            columnTitles = VARIANT(pythoncom.VT_ARRAY |
            pythoncom.VT_BSTR, [""])<br>
                        columnPos = VARIANT(pythoncom.VT_ARRAY |
            pythoncom.VT_I4, [0])<br>
                        object.GetTableInfo("TABLENAME", columnTitles,
            columnPos)</div>
          <div><br>
          </div>
          <div>but I get an error: </div>
          <div>Object ot type VARIANT has no len()</div>
          <div><br>
          </div>
          <div>What I am doing wrong ?</div>
          <div><br>
          </div>
          <div>Thanks in advance.</div>
          <div><br>
          </div>
        </div>
        <br>
        <fieldset class="moz-mime-attachment-header"></fieldset>
        <pre wrap="" class="moz-quote-pre">_______________________________________________
python-win32 mailing list
<a class="moz-txt-link-abbreviated moz-txt-link-freetext"
        href="mailto:[email protected]" moz-do-not-send="true">[email protected]</a>
<a class="moz-txt-link-freetext"
        href="https://mail.python.org/mailman/listinfo/python-win32"
        moz-do-not-send="true">https://mail.python.org/mailman/listinfo/python-win32</a>
</pre>
      </blockquote>
    </div>
  </body>
</html>

--------------u3LoGaBF1b0GW9kkQ5bWjImW--

--===============6727823369814206808==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32

--===============6727823369814206808==--