if (spHTML) { // Get the BODY object CComQIPtr<IHTMLElement, &IID_IHTMLElement> pBody; HRESULT hr = spHTML->get_body(&pBody); if (FAILED(hr)) return ; // Get the HTML text BSTR bstrHTMLText; hr = pBody->get_outerHTML(&bstrHTMLText); if (FAILED(hr)) return ; // Convert the text from Unicode to ANSI LPTSTR psz = new TCHAR[SysStringLen(bstrHTMLText)]; lstrcpy(psz, OLE2T(bstrHTMLText));
CComPtr<IDispatch> pDocDisp;
pDocDisp = m_wndWebBrowser.GetDocument();
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML;
spHTML = pDocDisp;
if (spHTML)
{
// Get the BODY object
CComQIPtr<IHTMLElement, &IID_IHTMLElement> pBody;
HRESULT hr = spHTML->get_body(&pBody);
if (FAILED(hr))
return ; // Get the HTML text
BSTR bstrHTMLText;
hr = pBody->get_outerHTML(&bstrHTMLText);
if (FAILED(hr))
return ; // Convert the text from Unicode to ANSI
LPTSTR psz = new TCHAR[SysStringLen(bstrHTMLText)];
lstrcpy(psz, OLE2T(bstrHTMLText));
MessageBox(psz,"data"); delete[] psz; }