i'm trying to call some COM methods from java through the com4j library. In the documentation I have access to, the COM method's signature is:
HRESULT method1 ([in] VARIANT (SafeArray UI1) vInBuf,
[out] VARIANT (SafeArray UI1) *pvOutBuf,
[out, retval] long *plResult)
I want to pass a byte array into that method and get a byte array out of it. The Com4J generated interface shows up as:
@DISPID(2)
@VTID(8)
int method1 (
@MarshalAs(NativeType.VARIANT) java.lang.Object vSendData,
java.lang.Object pvReceiveData);
However I don't know what format to send them in.
byte[] req = new byte[]{1,2,3,4};
byte[] res = new byte[512];
method1(req,res);
does not seem to work. Neither does declaring them as objects or whatnot. I've looked into com4j.SafeArray (http://com4j.kohsuke.org/apidocs/com4j/SafeArray.html), but I can't quite make sense of how I'm supposed to put an array into it.
Has anyone else ever used the com4j libraries and figured out how to send/receive arrays of bytes?