2

I need to pass list of Booleans values to COM as VT_ARRAY.

from win32com.client import Dispatch, VARIANT
import pythoncom

api = Dispatch("MyAPI")
controller = api.CreateInterface()
first = VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_BOOL, [True, False, True])
second = VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_BOOL, [True, False, True])
controller.MyMethod(first, second) 

C++ code of COM interface is:

if ( first->vt == ( VT_ARRAY | VT_BOOL ) && second->vt == ( VT_ARRAY | VT_BOOL ) )
    {
        CComSafeArray<BOOL> first_safe( first->parray ); //fails here
        CComSafeArray<BOOL> second_safe( second->parray );

Fails whith COM exception on python side:

pywintypes.com_error: (-2147023170, 'The remote procedure call failed.', None, None)
Denis
  • 63
  • 4

0 Answers0