This is about getting the URL address (VC + +) that is opened when IE, and automatically printing out the corresponding URL source code content:
Put this in your header file stdafx.h #import <mshtml.tlb> #import <shdocvw.dll> void CGETIESRCDLG::GETRUNNINGIESR
C () {shdocvw::ishellwindowsptr m_spshwinds;
CoInitialize (NULL);
if (M_spshwinds.createinstance (__uuidof (shdocvw::shellwindows)) = = S_OK) {idispatchptr spdisp;
Long ncount = M_spshwinds->getcount (); for (long i = 0; i < ncount;
i++) {_variant_t va (i, VT_I4);
Spdisp = M_spshwinds->item (VA);
Shdocvw::iwebbrowser2ptr Spbrowser (SPDISP);
if (Spbrowser!= NULL) {idispatchptr spdisp; if (spbrowser->get_document (&spdisp) = = S_OK && spdisp!= 0) {mshtml::ihtmldocument2ptr S
Phtmldocument (SPDISP);
Mshtml::ihtmlelementptr sphtmlelement;
if (sphtmldocument==null) continue;
Sphtmldocument->get_body (&sphtmlelement);
if (sphtmldocument==null) continue;
_bstr_t str;
Str=spbrowser->getlocationurl ();//url of IE window (); AfXmessagebox (str);
mshtml::ihtmldocument3* pHTMLDoc3;
HRESULT hr = Sphtmldocument->queryinterface (__uuidof (Mshtml::ihtmldocument3), (lpvoid*) &phtmldoc3);
ASSERT (SUCCEEDED (HR));
mshtml::ihtmlelement* Pdocelem;
hr = Phtmldoc3->get_documentelement (&pdocelem);
Phtmldoc3->release ();
ASSERT (SUCCEEDED (HR));
BSTR bstrhtml;
Pdocelem->get_outerhtml (&bstrhtml);
Pdocelem->release ();
AfxMessageBox (CString (bstrhtml));
SysFreeString (bstrhtml);
} break;
}} else {AfxMessageBox ("Shell Windows interface is not avilable");
} couninitialize (); }
Description: Simply traverse all the nodes of the entire Web page, find the first page in the container (the first page of multiple IE pages), and then traverse to remove all child nodes and print. We can test it, because sometimes the Web page of the General Assembly of suspended animation phenomenon, this code this studio test, you can use, but the use of IE7,IE8 so many tabs page of the browser to find the contents of each tab may also need to change, interested friends to try it yourself!
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/vc/