int dispIdMember,
int wFlags,
Variant[] rgvarg,
int[] rgdispidNamedArgs,
Variant pVarResult) throws Exception {
IDispatch objIDispatch = (IDispatch) ReflectionUtils.getFieldObject(automation, "objIDispatch");
// get the IDispatch interface for the control
if (objIDispatch == null)
return COM.E_FAIL;
// create a DISPPARAMS structure for the input parameters
DISPPARAMS pDispParams = new DISPPARAMS();
// store arguments in rgvarg
if (rgvarg != null && rgvarg.length > 0) {
pDispParams.cArgs = rgvarg.length;
pDispParams.rgvarg =
OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof * rgvarg.length);
int offset = 0;
for (int i = rgvarg.length - 1; i >= 0; i--) {
ReflectionUtils.invokeMethod(rgvarg[i], "getData(int)", pDispParams.rgvarg + offset);
offset += VARIANT.sizeof;
}
}
// if arguments have ids, store the ids in rgdispidNamedArgs
if (rgdispidNamedArgs != null && rgdispidNamedArgs.length > 0) {
pDispParams.cNamedArgs = rgdispidNamedArgs.length;
pDispParams.rgdispidNamedArgs =
OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length);
int offset = 0;
for (int i = rgdispidNamedArgs.length; i > 0; i--) {
COM.MoveMemory(
pDispParams.rgdispidNamedArgs + offset,
new int[]{rgdispidNamedArgs[i - 1]},
4);
offset += 4;
}
}
// invoke the method
EXCEPINFO excepInfo = new EXCEPINFO();
int[] pArgErr = new int[1];
int /*long*/pVarResultAddress = 0;
if (pVarResult != null)
pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, VARIANT.sizeof);
int result =
objIDispatch.Invoke(
dispIdMember,
new GUID(),
COM.LOCALE_USER_DEFAULT,
wFlags,
pDispParams,