my binarycode cannot add new object in window, but javascript can do.

in javascript,we can add a new object in the window like this:

<script language=javascript>

window.testObj=new ActiveXObject("XXX.YYY");

window.testObj.dosomething();

</script> .

I want directly add a new object in the window in my BHO through the IDispatchEx,
but I always get the error result with0x80020003 Member not found , anyone could tell me why?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

......

CComPtr<IHTMLWindow2> pWindow;

......Get the window object in other code.

//get the IDispatchEx of window
CComPtr<IDispatchEx> pWinEx;
HRESULT hr=pWindow->QueryInterface(IID_IDispatchEx,(void**)&pWinEx);
if(FAILED(hr))
return hr;

//create a new element in window
DISPID dispid;
CComBSTR bstrAgent=L"testObj";
hr=pWinEx->GetDispID(bstrAgent,fdexNameEnsure,&dispid);
if(FAILED(hr))
return hr;

VARIANT var;
DISPID putid;
DISPPARAMS dispparams;

//Assign the pDispForSomeObject to the window.testObj

putid = DISPID_PROPERTYPUT;
var.vt = VT_DISPATCH;
var.pdispVal = pDispForSomeObject;
dispparams.rgvarg = &var;
dispparams.rgdispidNamedArgs = &putid;
dispparams.cArgs = 1;
dispparams.cNamedArgs = 1;
hr = pWinEx->InvokeEx(dispid, LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYPUTREF, &dispparams,
NULL, NULL, NULL);
/////////////////////////////////////// hr =0x80020003 Member not found

return S_OK;

[1722 byte] By [kevin7776] at [2008-3-6]
# 1
did you ever solve this problem?
impactmrj at 2007-9-3 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...