代码如下:CComPtr< IWebBrowser2 > spWB2;
//spWB2.CoCreateInstance( CLSID_InternetExplorer );
spWB2.CoCreateInstance( CLSID_WebBrowser );CComVariant flag;
CComVariant empty;CComBSTR url;
spWB2->Navigate( url, &flag, &empty, &empty, &empty );while( !IsDocumentReady( spWB2.p ) )
Sleep( 500 );CComPtr< IDispatch > spDisp;
spWB2->get_Document( &spDisp );如果使用CLSID_InternetExplorer,可以获得网页,
但如果使用CLSID_WebBrowser,就不行了,有没有方法使用WebBrowser,而不是IE?

解决方案 »

  1.   

    可以考虑用DIID_DWebBrowserEvents2实现
      

  2.   

    可能是没有下载完你就执行 get_Documents()了,所以取的是空指针。
    while( !IsDocumentReady( spWB2.p ) )
    Sleep( 500 );
    -------------
    去掉这个。CComPtr< IDispatch > spDisp;
    spWB2->get_Document( &spDisp );
    ---------------------------------
    把这段的功能放在OnDocumentComplete事件中。
      

  3.   

    那为什么使用CLSID_InternetExplorer就可以了,当使用CLSID_WebBrowser的时候,
    while( !IsDocumentReady( spWB2.p ) )
    Sleep( 500 );总是在执行,等了很久也不会退出。