Does anyone know how you can call a method of a prototype in Javascript from C++?
I have an pointer to script IDispatch, and I can get the IDsOfNames for the prototype, but I can't find how to get the IDispatch of it's member function.
Say (pseudocode):
JSprototype foo
{
method bar(baz);
}
I can get a valid DISPID of foo, but I don't know how to call bar(baz)
. Does anyone have an idea?
That's what
IDispatch::Invoke
is for. You don't need a separateIDispatch
for every function. However, you do need a DISPID ofbar
, and therefore anIDispatch
offoo
. That means you'll have to calliFoo->Invoke(DISPID_bar)
andQueryInterface(IDispatch)
the result.