comtypes icon indicating copy to clipboard operation
comtypes copied to clipboard

Can't create VARIANT with typecode VT_ARRAY | BT_BSTR

Open net147 opened this issue 9 years ago • 1 comments

http://pythonhosted.org/comtypes/#converting-data-types mentions that some COM server methods require an array of strings with typecode VT_ARRAY | VT_BSTR. Currently, there doesn't seem to be a method of creating a VARIANT with typecode VT_ARRAY | VT_BSTR.

net147 avatar Jun 12 '15 13:06 net147

A workaround for this issue:

Start from line 301 of automation.py

elif isinstance(value, (list, tuple)):
    if isinstance(value[0], str):
        obj = _midlSAFEARRAY(BSTR).create(value)
    else:
        obj = _midlSAFEARRAY(VARIANT).create(value)
    memmove(byref(self._), byref(obj), sizeof(obj))
    self.vt = VT_ARRAY | obj._vartype

bsha0 avatar Apr 24 '22 15:04 bsha0