CSDN博客

img davidhua2000

网址拦截和弹出窗口的屏蔽

发表于2004/9/21 17:46:00  377人阅读

STDMETHODIMP CIEPlugCom::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pvarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
 USES_CONVERSION;
 
 if(!pDispParams)
  return E_INVALIDARG;
 
 LPOLESTR lpURL=NULL;
 m_spWebBrowser2->get_LocationURL(&lpURL); 
 switch(dispidMember)
 {
 case DISPID_BEFORENAVIGATE2:
  char *pURL;
  if(pDispParams->cArgs >=5&&pDispParams->rgvarg[5].vt==(VT_BYREF|VT_VARIANT))
  {
            CComVariant varURL(*pDispParams->rgvarg[5].pvarVal);
            varURL.ChangeType(VT_BSTR);
   //转化要访问的网址为char *型
   pURL=OLE2A(varURL.bstrVal);
  }
  //如果正要访问的网址为要被拦截的,则停止  
  //IDS_URL
  if(strstr(pURL,"microsoft.com")!=NULL)
  {
            *pDispParams->rgvarg[0].pboolVal=TRUE;
      MessageBox(NULL,"当前系统禁止浏览该页","警告",MB_ICONSTOP);
   return S_OK;
  }
  break;
 case DISPID_NAVIGATECOMPLETE2:
  break;
 case DISPID_DOCUMENTCOMPLETE:
  break;
 case DISPID_DOWNLOADBEGIN:
  break;
 case DISPID_DOWNLOADCOMPLETE:
  break;
 case DISPID_NEWWINDOW2:
  READYSTATE m_ReadyState;
        m_spWebBrowser2->get_ReadyState(&m_ReadyState);
        if(m_ReadyState!=READYSTATE_COMPLETE)
        {
            *pDispParams->rgvarg[0].pboolVal=TRUE;
            return S_OK;
        }
  else
  {
            *pDispParams->rgvarg[0].pboolVal=FALSE;
            return S_OK;
  }
     break;
 case DISPID_QUIT:
  break;
 default:
  break;
 }
 return S_OK;
}
0 0

相关博文

我的热门文章

img
取 消
img