HRESULT hr = _Browser->get_Document(&document_dispatch);停在这里了,该如何处理

HRESULT hr = _Browser->get_Document(&document_dispatch);停在这里了
程序想实现获取html代码,然后在webbrowser控件中显示,代码如下
C/C++ code

void CWebBrowser2::Write( LPCTSTR string )
{
    if (_Browser != NULL) {

        // get document interface

        IHTMLDocument2 *document = GetDocument_File();

        if (document != NULL) {

            // construct text to be written to browser as SAFEARRAY

            SAFEARRAY *safe_array = SafeArrayCreateVector(VT_VARIANT,0,1);

            VARIANT    *variant;

            SafeArrayAccessData(safe_array,(LPVOID *)&variant);

            variant->vt      = VT_BSTR;
            variant->bstrVal = CString(string).AllocSysString();

            SafeArrayUnaccessData(safe_array);

            // write SAFEARRAY to browser document

            document->write(safe_array);

            document->Release();
            document = NULL;

        }

    }

}
/********************************************************************************/
IHTMLDocument2 * CWebBrowser2::GetDocument_File()
{

    IHTMLDocument2 *document = NULL;

    if (_Browser != NULL) {

        IDispatch *document_dispatch = NULL;

        HRESULT hr = _Browser->get_Document(&document_dispatch);   // [color=#FF0000] 到这里提示我说冲突,不知为什么[/color]

        if (SUCCEEDED(hr) && (document_dispatch != NULL)) {

            // get the actual document interface

            hr = document_dispatch->QueryInterface(IID_IHTMLDocument2,
                (void **)&document);

            document_dispatch->Release();

        }

    }

    return document;
}


调用该方法时,m_strShowMsg.Write(strNewString); strNewString获取的就是所有的html信息,但是运行到以上部分的时候,提示错误,忘大侠指点

------解决方案--------------------
//通过IWebBrowser2获取IHTMLDocument2接口
CComPtr<IDispatch> spDispDoc; 
hr=m_pWebBrowser->get_Document(&spDispDoc); 
if (FAILED(hr)) return false; 
CComQIPtr<IHTMLDocument2>pHtmlDoc =spDispDoc; 
if (!pHtmlDoc) return false; 

以上這段代碼才我這裡通過。
我分析了一下,你參看參考。
1._Browser是什麼,是不是一個有效的 IWebBrowser2 指針?