#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