Python -COMMETHOD ,No return value obtained/received

sanju dhoomakethu otlasanju at gmail.com
Fri Sep 13 01:55:13 EDT 2013


I am very new to COM programming, Our project requires the Python script to make communication with a COM dll which is written in C#.

The generated COM signature in Python is as below

COMMETHOD([dispid(1610743820)], HRESULT, 'test',
          ( ['in', 'out'], POINTER(_midlSAFEARRAY(c_double)), 'test' ),
          ( ['retval', 'out'], POINTER(VARIANT_BOOL), 'pRetVal' )),
Where as the C# code for the same is

public bool test(ref double[,] test)
        {
            if (test == null)
                test = new double[1,2];


            test[0,0] = 0.0;
            test[0,1] = 0.5;

            return true;
        }
Note: the above is the dummy functions i have created to explain the issue

Now when I try to invoke the COM method from Python , I am only getting the values passed by reference to the method (sweepValuesX) as return value and not the actual return value (which has to be either true/false)

My function call is as below

print apxWrapper.test()
and the output is ((0.0, 0.5),)

Note: Since i was not able to find a way to pass the last arguement from Python ,I just omitted the last argument for trial purpose

Any hints why this is happening is highly appreciated or to be specific I have two questions

1> How Can i pass the argument to be passed by reference from Python especially array (both single and multidimensional)(POINTER(_midlSAFEARRAY(c_double)))
2> How can i get the actual return value (true/false)
Sanjay



More information about the Python-list mailing list