2012-07-28 53 views
0

發生此是我在OnBtnClick功能編寫代碼運行時檢查失敗#0的時候我叫IHTMLDocument3 :: getElememntById功能MFC

CComPtr<IHTMLDocument3> pDoc3 = (IHTMLDocument3 *)m_webBrowser.get_Document(); 
CComPtr<IHTMLElement> pElem; 
BSTR idTmp = CComBSTR(L"article_summary"); 
HRESULT hr = pDoc3->getElementById(idTmp, &pElem); 

我試圖讓哪個ID是元素「article_sumary」...但我得到了這個

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function 
call. This is usually a result of calling a function declared with one calling 
convention with a function pointer declared with a different calling convention. 

回答

1

第一次演員你看起來很討厭。我會得到未鑄造的文檔類型(IHTMLDocument2?),然後在其上執行查詢接口到IHTMLDocument3。

CComPtr<IHTMLDocument2> pDoc2 = m_webBrowser.get_Document();// assuming it returns IHTMLDocument2 

CComPtr<IHTMLDocument3> pDoc3; 
pDoc2->QueryInterface(&pDoc3); 
+0

哇,這正是我剛纔所做的。我讀了Essntial COM,然後更改我的代碼...我只是COM的開端。運行時檢查失敗#0誤導我兩天! – 2012-07-28 16:36:54

相關問題