Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Debug assertion failed when I try to connect to IE Events

Debug assertion failed when I try to connect to IE Events

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Cramer
    wrote on last edited by
    #1

    Hi! That's my code to start IE and connect to its events:

    void CMFCIEEvtSpyDlg::OnStartIE()
    {
    if (m_pIE == NULL) // Can only start one instance
    {
    // Create an instance of Internet Explorer
    HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
    IID_IWebBrowser2, (void**)&m_pIE);
    if (SUCCEEDED(hr))
    {
    // Set up the event sink
    BOOL bAdvised = AfxConnectionAdvise(m_pIE, DIID_DWebBrowserEvents2,
    m_pIE4Events->GetInterface(&IID_IUnknown),
    TRUE, &m_dwCookie);

         TRACE("Advise for DWebBrowserEvents2 %s\\n", bAdvised ? "succeeded" : "failed"); 
    
         m\_btnStartIE.EnableWindow(FALSE); 
    
         // Make IE visible 
         m\_pIE->put\_Visible(VARIANT\_TRUE); 
    
         CString strURL; 
         strURL.LoadString(IDS\_HOME\_PAGE); 
    
         COleVariant vtEmpty; 
         m\_pIE->Navigate(strURL.AllocSysString(), &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty); 
      } 
    

    }
    }

    In release bild all works correctly, but in Debug function call m_pIE4Events->GetInterface(&IID_IUnknown) failed (returns NULL). I can't understand, why. Here's a source and compilied release (65 K) [new browser window]. Please, help me!! Thanks!

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups