CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

Home >> Visual C++ / C++ >> Internet & Networking >> IE Programming


Connecting to Running Instances of Internet Explorer
Rating: none

Venu Vemula & Robert Walker (view profile)
January 16, 2001

There has been always a problem connecting to web browsers, Either you need to write Browser Helper Object or something which browser needs to instantiate. But I found all the other methods had one or other way bug in it. Decided to find simple and bug free way, And came across this ShellWindows interface, which is used by Shell to keep track all the shell browsers including Shell Folders and Internet explorers I Believe shell uses name spaces to keep track of this windows.

Not only shell windows keeps track of all shell windows and also notifies when new shell window is created or deleted.
(continued)



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");
  }
 }
}

Downloads

Download source - 15 Kb

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
Apllication crashes when trying to read URL's in a timer?? - Legacy CodeGuru (01/24/2004)
crashing problem? abnormal program termination - Legacy CodeGuru (01/06/2004)
DocumentComplete() / NavigateComplete2() technique - Legacy CodeGuru (11/01/2003)
URGENT - Calling IE programmatically and Hiding display - Legacy CodeGuru (10/30/2003)
How can I set the proxy to use by connected running instance - Legacy CodeGuru (08/14/2003)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers