请教:如何用VC得到当前IE正在浏览的网页的网址和title? VC/MFC / HTML/XML

来源:百度文库 编辑:神马文学网 时间:2024/04/24 14:01:23
#import     //   Internet   Explorer   5
#import  
//Declare   an   instance   of   an   IShellWindows   pointer   in   your   view   class:
SHDocVw::IShellWindowsPtr   m_spSHWinds;
ListBox   m_ctrListLoc;   //add   by   myself
//Create   an   instance   of   a   ShellWindows   object   in   your   view's   constructor:
m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows));
//Use   the   ShellWindows   object   in   your   view's   OnInitialUpdate   function:
void   CConnectIEView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
ASSERT(m_spSHWinds   !=   NULL);
CString   strCount;
long   nCount   =   m_spSHWinds->GetCount();
strCount.Format("%i",   nCount);
m_strWinCount   =   strCount;
UpdateData(FALSE);
IDispatchPtr   spDisp;
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)
{
m_ctlListLoc.AddString(spBrowser->GetLocationName());
MSHTML::IHTMLDocument2Ptr   spDoc(spBrowser->GetDocument());
if   (spDoc   !=   NULL)
{
m_ctlListTitle.AddString(spDoc->Gettitle());
}
}
}
}
//   from   q176792.   ruxming   Edited.
http://support.microsoft.com/default.aspx?scid=KB;en-us;q176792