IDispatch* spDisp =NULL;
IHTMLDocument2* spDoc2 ;HRESULT rs = spDoc2->get_Script( &spDisp);错误 了错误rs 是个负值
spDisp是ox000000000

解决方案 »

  1.   

    Doc怎么获得的
    在什么时候取的脚本
      

  2.   

    void GetDocInterfacex(HWND hWnd)
    {
    CoInitialize( NULL );
    // Explicitly load MSAA so we know if it's installed
    HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
    if ( hInst != NULL )
    {
    if ( hWnd != NULL )
    {
    HWND hWndChild=NULL;
    // Get 1st document window
    ::EnumChildWindows( hWnd, EnumChildProc, (LPARAM)&hWndChild );
    if ( hWndChild )
    {
    CComPtr<IHTMLDocument2> spDoc;
    LRESULT lRes; UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
    ::SendMessageTimeout( hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes ); LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult") );
    if ( pfObjectFromLresult != NULL )
    {
    HRESULT hr;
    hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0, (void**)&spDoc );
    if ( SUCCEEDED(hr) )
    {
    printf("sdsdsdssdsdsdsd\r\n");
    FilterWeb(spDoc);
    // CComPtr<IDispatch> spDisp;
    // CComQIPtr<IHTMLWindow2> spWin;
    // spDoc->get_Script( &spDisp );
    // spWin = spDisp;
    // spWin->get_document( &spDoc.p );
    // // Change background color to red
    // spDoc->put_bgColor( CComVariant("red") );
    }
    }
    } // else document not ready
    } // else Internet Explorer is not running
    ::FreeLibrary( hInst );
    } // else Active Accessibility is not installed
    CoUninitialize();
    }
      

  3.   

    // CComPtr<IDispatch> spDisp;
    // CComQIPtr<IHTMLWindow2> spWin;
    // spDoc->get_Script( &spDisp );
    // spWin = spDisp;
    // spWin->get_document( &spDoc.p );
    // // Change background color to red
    // spDoc->put_bgColor( CComVarian("red") );
    这个代码没有用,我有自己的处理 ,在另一个函数中进行处理的
      

  4.   

    这样啊
    你要判断document的ready state
      

  5.   

    FilterWeb(spDoc);
    这个函数就是我自己处理的函数 ,用document 对象作为参数