I have an ATL component that is being used in IE via JScript. I need to return an object from this C++ ATL component so that it can be used in the JScript engine. For example:
<object name="MyObject" CLSID="03492034-MY-CLASS-I
result = MyObject.CallIntoATL();
//result["SomeAttribute"] will contain something set in the ATL component
Pseudo-C++-code for ATL component:
MyObject::InvokeEx(DISPID id, LCID lcid, WORD wFlags, DISPPARAMS* pdp, VARIANT* pvarRes, EXCEPINFO* pei, IServiceProvider* pspCaller)
// Do some stuff, check the id or whatever to call the method
pvarRes->vt = VT_DISPATCH; // Correct??
pvarRes->pdispVal = ????; // Need object with IDispatchEx interface?
// Basically I need to return a new JScript object in pvarRes.
Now looking at the Microsoft site I see an example that is probably what I want to do (look at the IDispatchEx stuff near the middle):
What they do is use "IDispatchEx *pdexScript" to create an object in the script engine and then I can return that in pvarRes. My problem is how do I get the IDispatchEx interface of the script engine? Their example just starts like:
BOOL test(IDispatchEx *pdexScript)
OK fine, but where does pdexScript come from?
I assume I can use the pspCaller service provider on my ATL object's InvokeEx method to query and get the IDispatchEx interface of the script engine but I can't figure how to do it.
Thanks for any help.