IWebBrowser2와 IHTMLDocument2의 상호변환

1. IWebBrowser2 에서 IHTMLDocument2 인터페이스 구하기

IWebBrowser2 *m_pWebFromUnknown;
IWebBrowser2 *m_pWebFromDoc;

STDMETHODIMP CTestObj::SetSite( IUnknown *pUnkSite )
{
    IOleClientSite *pClientSite;
    HRESULT hr;

    hr = pUnkSite-> QueryInterface( IID_IOleClientSite, 
    (LPVOID *)&pClientSite );
    if ( FAILED( hr ) ) return S_OK;

    IOleContainer *pContainer;
    hr = pClientSite-> GetContainer( &pContainer );
    pClientSite-> Release();
    if ( FAILED( hr ) ) return S_OK;
    
    IServiceProvider *pServiceProvider;
    hr = pContainer-> QueryInterface( IID_IServiceProvider, 
    (LPVOID *)&pServiceProvider );
    pContainer-> Release();
    if ( FAILED( hr ) ) return S_OK;

    hr = pServiceProvider-> QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, (LPVOID *)
                                         &m_pWebFromUnknown );
    pServiceProvider-> Release();
    if ( FAILED( hr ) ) return S_OK;

    LPDISPATCH pDocDisp;
    hr = m_pWebFromUnknown-> get_Document( &pDocDisp