仅供参考:
HRESULT hr;
IDispatch* lpDispatch;
lpDispatch = m_WebBrower.GetDocument();
IHTMLDocument2* lpDocument2;
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (PVOID*)&lpDocument2);
if ( hr == S_OK )
{
IHTMLElement * pBody;
lpDocument2->get_body(&pBody);
BSTR html;//存放html源代码
CComBSTR html_t;//用于将BSTR转换为cout可以处理的字符串
pBody->get_innerHTML(&html);
CString strCookie(html);
CFile myfile("1.html",CFile::modeWrite|CFile::modeCreate);
myfile.Write(strCookie,strCookie.GetLength());
myfile.Close();
pBody->Release();
lpDocument2->Release();
}
lpDispatch->Release();