Re: Calling a method with SAFEARRAY parameter

Alessandro Fiorino <[email protected]> Wed, 2 Oct 2024 08:31:48 +0200
Newsgroups gmane.comp.python.windows
Message-ID <CAAmYX6x8Bz4C1mNCQiq16hJJUW2GoNB_=OfEBxkBtjg7tsmw_g@mail.gmail.com>
--===============6196133096307109472==
Content-Type: multipart/alternative; boundary="0000000000008b6e950623789826"

--0000000000008b6e950623789826
Content-Type: text/plain; charset="UTF-8"

It worked it was easier than expected!

Il gio 26 set 2024, 07:11 Thomas Geppert <[email protected]> ha scritto:

> 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 [email protected]://mail.python.org/mailman/listinfo/python-win32
>
>

--0000000000008b6e950623789826
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">It worked it was easier than expected!</div><br><div clas=
s=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Il gio 26 set 2024,=
 07:11 Thomas Geppert &lt;<a href=3D"mailto:[email protected]">tgeppert@di=
gitx.de</a>&gt; ha scritto:<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

 =20
   =20
 =20
  <div>
    <p>You can simply pass a string and two empty lists like:</p>
    <p>titles, positions =3D GetTableInfo(&quot;TABLENAME&quot;, [], [])</p=
>
    <p><br>
    </p>
    <div>Am 25.09.2024 um 13:41 schrieb
      Alessandro Fiorino:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      <div dir=3D"ltr">
        <div>
          <p>
          </p>
          I have to call a method of a COM Object which is defined as</div>
        <div>GetTableInfo ([in] BSTR
          bstrTableName,[in, out] SAFEARRAY(BSTR)*bstrColumnTitles,[in,
          out] SAFEARRAY(long)*lColumnPos)</div>
        <div><br>
        </div>
        <div>I tried with</div>
        =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 columnTitles =3D VARIANT(=
pythoncom.VT_ARRAY |
        pythoncom.VT_BSTR, [None])<br>
        =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 columnPos =3D VARIANT(pyt=
honcom.VT_ARRAY |
        pythoncom.VT_I4, [None])<br>
        =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 object.GetTableInfo(&quot=
;TABLENAME&quot;, columnTitles,
        columnPos)
        <div>and with</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 columnTitles =3D VAR=
IANT(pythoncom.VT_ARRAY |
          pythoncom.VT_BSTR, [&quot;&quot;])<br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 columnPos =3D VARIANT(p=
ythoncom.VT_ARRAY |
          pythoncom.VT_I4, [0])<br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 object.GetTableInfo(&qu=
ot;TABLENAME&quot;, columnTitles,
          columnPos)</div>
        <div><br>
        </div>
        <div>but I get an error:=C2=A0</div>
        <div>Object ot type=C2=A0VARIANT 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></fieldset>
      <pre>_______________________________________________
python-win32 mailing list
<a href=3D"mailto:[email protected]" target=3D"_blank" rel=3D"norefer=
rer">[email protected]</a>
<a href=3D"https://mail.python.org/mailman/listinfo/python-win32" target=3D=
"_blank" rel=3D"noreferrer">https://mail.python.org/mailman/listinfo/python=
-win32</a>
</pre>
    </blockquote>
  </div>

</blockquote></div>

--0000000000008b6e950623789826--

--===============6196133096307109472==
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

--===============6196133096307109472==--