* the array of arguments. vArgs[0] is the this parameter supplied to the function, which
* must be null if it is static.
* @return the return value of the JavaScript function
*/
protected Variant doInvokeOnWindow2(OleAutomation window, String name, Variant[] vArgs) {
OleAutomation funcObj = null;
Variant funcObjVar = null;
try {
// Get the function object and its 'call' method.
//
int[] ids = window.getIDsOfNames(new String[]{name});
if (ids == null) {
throw new RuntimeException("Could not find a native method with the signature '"
+ name
+ "'");
}
int functionId = ids[0];
funcObjVar = window.getProperty(functionId);
funcObj = funcObjVar.getAutomation();
int callDispId = funcObj.getIDsOfNames(new String[]{"call"})[0];
// Invoke it and return the result.
//
return funcObj.invoke(callDispId, vArgs);
} finally {
if (funcObjVar != null) {
funcObjVar.dispose();
}
if (funcObj != null) {
funcObj.dispose();
}
}
}