From our Java program we need to invoke a COM method which is defined in VC++ 6 as follows:
DISP_FUNCTION(CServerDispatch, "MyMethod", myMethod, VT_I4, VTS_I4 VTS_PVARIANT)
As the last parameter (VTS_PVARIANT) the C++ program expects to get a Variant into which it wants to fill a newly created Variant. Into that other Variant, the C++ program fills in either a double (VT_I8) or a SafeArray<Double> (VT_ARRAY|VTR8).
Our C++ test client can invoke that and succeeds:
VariantClear(p2); static BYTE BASED_CODE types[] = VTS_I4 VTS_PVARIANT; InvokeHelper(0x9, DISPATCH_METHOD, VT_I4, (void*) &result, type, p1, p2);
The C++ test client then inspects p2's type to see whether it is a VT_I8 or a VT_ARRAY|VTR8.
So apparently the COM server is working well!
What we already tried to do in Java was:
Variant p2 = new Variant(); p2.changeType(Variant.VariantVariant); Dispatch.call(disp, "MyMethod", p1, p2);
But that leads to an error message at runtime:
com.jacob.com.ComFailException: A COM exception has been encountered: At Invoke of: MyMethod Description: 80020005 / Type mismatch.
What is our fault? How to do it correctly?
Log in to post a comment.
From our Java program we need to invoke a COM method which is defined in VC++ 6 as follows:
As the last parameter (VTS_PVARIANT) the C++ program expects to get a Variant into which it wants to fill a newly created Variant. Into that other Variant, the C++ program fills in either a double (VT_I8) or a SafeArray<Double> (VT_ARRAY|VTR8).
Our C++ test client can invoke that and succeeds:
The C++ test client then inspects p2's type to see whether it is a VT_I8 or a VT_ARRAY|VTR8.
So apparently the COM server is working well!
What we already tried to do in Java was:
But that leads to an error message at runtime:
What is our fault? How to do it correctly?
Last edit: Markus KARG 2015-06-25