Connecting to Running Instances of Internet Explorer
Posted
by Venu Vemula & Robert Walker
on January 16th, 2001
Not only shell windows keeps track of all shell windows and also notifies when new shell window is created or deleted.
When you enumerate, you can query whether the entry supports IWebBrowser interface, if it does it could be either WebBrowser or ShellBrowser. Once you get hold of IWebBrowser2 interface, you can either use it or listen to DWebBrowserEvents or through it away.
Before you start cranking in, you should include
#import "mshtml.tlb": // Internet Explorer 5
#import "shdocvw.dl"
Connecting To web browser using shell windows interface
void CIEEnumWindowsDlg::ConnectToShell()
{
CoInitialize(NULL);
if(m_spSHWinds == 0) {
//
// Get reference to ShellWindows interface
//
if(m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows))
== S_OK) {
// Event Sink
//
LPCONNECTIONPOINTCONTAINER pConnPtCont;
if ((m_spSHWinds != NULL) &&
SUCCEEDED(m_spSHWinds->QueryInterface(IID_IConnectionPointContainer,
(LPVOID*)&pConnPtCont))) {
ASSERT(pConnPtCont != NULL);
LPCONNECTIONPOINT pConnPt = NULL;
DWORD dwCookie = 0;
if (SUCCEEDED(pConnPtCont->FindConnectionPoint(
__uuidof(SHDocVw::DShellWindowsEvents), &pConnPt)))
{
ASSERT(pConnPt != NULL);
pConnPt->Advise( this->GetIDispatch(FALSE), &dwCookie);
pConnPt->Release();
}
pConnPtCont->Release();
}
}
else {
AfxMessageBox("Shell Windows interface is not avilable");
}
}
}

Comments
There are no comments yet. Be the first to comment!