Hey All !
I've just implemented all neccessary steps to use ActiveX scripting in my
app.
And I got a problem - in case of JScript something goes not that well.
Check this tiny func in JScript text file:
function on_CONNECT( msg )
{
Panel.Trace( "on_CONNECT (" + msg.Body + ")\n" );
return 0;
Quote:
}
msg = is the object (derived from CCmdTarget) which implemets some
properties & members via dispatch.
when calling function from JScript source, im passing IDispatch interface of
"msg" object into script:
VARIANT result; VARIANTARG arg; arg.vt = VT_DISPATCH; arg.pdispVal =
lpDispatch;
DISPPARAMS params = { &arg, NULL, 1, 0 };
m_dd.m_lpDispatch->Invoke( disp,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
¶ms,
&result,
NULL,
NULL
) ;
All is going just fine - function executes, etc. BUT, after returning back
to my app I've found that m_dwRef member of msg object is increased by one !
Seems like JScript were holding some interface of msg object inside... This
lead me to GPF, couse msg object is temporary (on stack)...
And, this does not happens when using VBScript engine, only when using
JScript !!!
Here is the same code for VBscript which works just fine :
Function on_CONNECT( ByVal msg )
call Panel.Trace( "on_CONNECT (" & msg.Body & ")" & NL )
End Function
What should I do ? Is there any tip about function declaration in JScript
which helps me here ? Can't find it on MS sites
(MSDN etc)
Yury Zenkevich,
STAC Estonia.