Debug assertion failed when I try to connect to IE Events
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
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!