SAFEARRAY(IDispatch*) problem in matlab
-
Hi all, I create a COM in VC++. It has a funtion that returns a SAFEARRAY (IDispatch*) . if I use this Com in c++, it works fine, but if I call this function in matlab, it causes problem. Does any one have experience on it? Thank you for any help. Tran Phuong Nga
-
Hi all, I create a COM in VC++. It has a funtion that returns a SAFEARRAY (IDispatch*) . if I use this Com in c++, it works fine, but if I call this function in matlab, it causes problem. Does any one have experience on it? Thank you for any help. Tran Phuong Nga
-
Try wrapping it into a VARIANT instead. I.e.
HRESULT MyMethod([out,retval] VARIANT * pVar);
And the variant is initialized like this (roughly):VARIANT l_var; VariantInit(&l_var); l_var.vt = VT_DISPATCH | VT_ARRAY; l_var.parray = your_safe_array;
Hi, thank you for your help. But the problem comes from the following code: SafeArrayCreateVector(VT_DISPATCH, 0, length);. If I hide this code, no problem any more. If the code is SafeArrayCreateVector(VT_INT, 0, length); or SafeArrayCreateVector(VT_BSTR, 0, length);.., no problem. So eventhough I wrap the return value into VARIANT type, I still have to call SafeArrayCreateVector(VT_DISPATCH, 0, length);, then the problem is still there. Do you know how to solve it, or is there any other ways to create a vector of IDispatch*? Thank you. Nga