HTMLDocument3 getElementById Run-Time Check Failure #0

错误代码:

	IHTMLDocument3* pHtmlDoc3 =(IHTMLDocument3*)CHtmlView::GetHtmlDocument();
	CComBSTR id("exchange_offers");
	IHTMLElement* pDiv = NULL;
	HRESULT hr = pHtmlDoc3->getElementById(id, &pDiv);

正确代码:

	IDispatch* pHtml = GetHtmlDocument();
	IHTMLElement * pElem = NULL;
	IHTMLDocument3* pHtmlDoc = NULL;
	IHTMLElement* pDiv = NULL;
	HRESULT hr = pHtml->QueryInterface(IID_IHTMLDocument3, (void **)&pHtmlDoc);
	CComBSTR id("exchange_offers");
	pHtmlDoc->getElementById(id, &pElem);

参考:

http://bbs.csdn.net/topics/330002515

http://hi.baidu.com/jjxiaoyan/item/22fe16b161b1a4f163388e43

你可能感兴趣的:(HTMLDocument3 getElementById Run-Time Check Failure #0)