I have a BHO Internet Explorer that can execute a script on the current website and then read the variables that were assigned in this script. Unfortunately, with IE9 (I tested with RC), reading the JS variable results in HRESULT 0x80020006.
The script set assigns the JS variable as follows:
this.<js_var> = <value>
where this
is the current Window object. It is executed using
hr = pWindow->execScript( ccom_js, lang, &vEmpty );
and the js variable is read using
bool get_js_var( CComPtr<IDispatch> pDisp, LPOLESTR name, VARIANT *dest )
{
DISPID id;
HRESULT hr = pDisp->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, &id );
if ( SUCCEEDED( hr ) ) {
VariantInit( dest );
VariantClear( dest );
DISPPARAMS dp = { 0, 0, 0, 0 };
hr = pDisp->Invoke( id, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dp, dest, NULL, NULL );
if ( SUCCEEDED( hr ) ) {
return true;
} else {
LOG( _T( "failed to get var contents, hresult = 0x%lx" ), hr );
}
} else {
LOG( _T( "failed to get id of var name, hresult = 0x%lx" ), hr );
}
return false;
}
where pDisp
obtained with document->get_Script( &pDisp );
.
This code works fine in previous versions of IE, in Windows XP, Vista, and 7. In IE9, a script is executed (I can raise warnings, etc.), but the variable cannot be read. What change in IE9 is causing this problem?