1. Register JS functions with ActiveX:
Add the interface method void registerfunction (BSTR bstrfuncname, idispatch * dispfunc) to ActiveX );
JavasBytesCodeDeclare a function and call the registerfunction interface to register the function with ActiveX for ActiveX to call.
2. Save the registered FunctionActivex uses the ccomdispatchdriver object to save the registered JS function (idispatch interface pointer)
Ccomdispatchdriver m_func1;
Void registerfunction (BSTR bstrfuncname, idispatch * dispfunc)
{
If (bstrfuncname = "1 ")
M_func1 = dispfunc;
}
3. Call the registered FunctionActivex uses the ccomdispatchdriver: invoken function to call the registered function.
The following is a call to a JS function that accepts an unsigned integer parameter:
Variant vararg [1];
Vararg [0]. Vt = vt_uint; vararg [0]. uintval = 1;
Try {
M_func1.invoken (dispid) dispid_value, vararg, 1 );
}
Catch (...){}
4. NoteThe JS function must be called in ActiveXProgramIn the main thread!
from: http://www.cnblogs.com/wxy8/archive/2011/04/06/2006743.html