不知道具体弄。。
谢谢

解决方案 »

  1.   

    IHTMLDocument2没有location这个东西啊,我的url是个CString类型的啊,怎么建立起来
      

  2.   

    http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/document2/get_location.asp
    http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/location/href.asp
      

  3.   

    HRESULT IHTMLDocument2::get_URL(BSTR *p);传进BSTR 然后转一下就可以了,USES_CONVERSION ;BSTR bsrt ;
    IHTMLDocument2::get_URL(&bstr);char szUrl[MAX_URL] ;
    strcpy( szUrl , OLE2A(bstr)) ;
      

  4.   

    你是想通过URL,得到IHTMLDocument2接口?
      

  5.   

    楼主要 url网址和IHTMLDocument2 的什么关系呀?
      

  6.   

    我的意思是从url得到IHTMLDocument2这个接口
      

  7.   

    通过URL直接得到有点困难,可以通过Webbrowser加载后,再得到。
      

  8.   

    楼主可以触发一下url的事件
    然后就可以得到接口了
    如果直接得到确实有些困难!
    我也在研究!
      

  9.   

    CoInitialize(NULL); 
    CString rString;
    HRESULT hr = S_OK;
    m_wndEditAddress.GetWindowText(rString);
             CComPtr<IWebBrowser2> pWebBrowser2;
    hr = CoCreateInstance(CLSID_InternetExplorer,
    NULL,CLSCTX_LOCAL_SERVER,
    IID_IWebBrowser2,(void  **)&pWebBrowser2); 
    ASSERT(E_FAIL  != hr); if(E_FAIL == hr) return hr;
               //access the web.
     COleVariant vaURL;
     vaURL = this->m_strAddress.AllocSysString(); //我用的www.163.com做测试
              COleVariant null; 
     hr = m_pWebBrowser2->Navigate2(vaURL,null,null,null,null);
              ASSERT(S_OK == hr);
     if(S_OK != hr) 
     {
     AfxMessageBox(_T("Address error!"));
     return hr;
     }
               //Wait For Document Completed.
    while(GetBusy() || GetReadyState() - READYSTATE_COMPLETE)
        Sleep(0x200);
              hr = pWebBrowser2->get_Document(&m_spDispatch);  
     ASSERT(S_OK == hr); 
     if(S_OK != hr) 
     {
     AfxMessageBox(_T("Can't load Docment!"));
     return hr;
     }
              CoInitialize();