Argletoast
February 9th, 2005, 11:27 AM
I have been set with a task to write a simple internet content filter for internet explorer, something much like Net Nanny and other such programs.
I use the COM interfaces which Internet Explorer makes available, namely IWebBrowser2, and can successfully block and allow websites according to their URL.
My problem is that I would also like to give the option of disabling images from being displayed/downloaded.
After some research into the topic, I see that I must use an ICustomDoc interface, which is obtained by calling QueryInterface on a IHTMLDocument2 interface, requesting an IID_ICustomDoc.
When I do this QueryInterface always returns E_NOINTERFACE.
HRESULT IDispatch::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
LPDISPATCH lpDispatch;
switch(dispIdMember)
{
case DISPID_NAVIGATECOMPLETE2:
lpDispatch = pDispParams->rgvarg[1].pvarVal->pdispVal;
hResult = lpDispatch->QueryInterface(IID_IWebBrowser2, (void**)&Web);
hResult = Web->get_Document(&pHTMLDocument);
hResult = pHTMLDocument->QueryInterface(IID_ICustomDoc, (LPVOID*)&CustomDoc);
// hResult is always E_NOINTERFACE after this call.
break;
}
}
Can anyone suggest a solution here? See whats going wrong?
I use the COM interfaces which Internet Explorer makes available, namely IWebBrowser2, and can successfully block and allow websites according to their URL.
My problem is that I would also like to give the option of disabling images from being displayed/downloaded.
After some research into the topic, I see that I must use an ICustomDoc interface, which is obtained by calling QueryInterface on a IHTMLDocument2 interface, requesting an IID_ICustomDoc.
When I do this QueryInterface always returns E_NOINTERFACE.
HRESULT IDispatch::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
LPDISPATCH lpDispatch;
switch(dispIdMember)
{
case DISPID_NAVIGATECOMPLETE2:
lpDispatch = pDispParams->rgvarg[1].pvarVal->pdispVal;
hResult = lpDispatch->QueryInterface(IID_IWebBrowser2, (void**)&Web);
hResult = Web->get_Document(&pHTMLDocument);
hResult = pHTMLDocument->QueryInterface(IID_ICustomDoc, (LPVOID*)&CustomDoc);
// hResult is always E_NOINTERFACE after this call.
break;
}
}
Can anyone suggest a solution here? See whats going wrong?