title: Connect to running IE instance C++
body: <p>I'm currently writing a program in AutoIt but I want to outsource some functions to C++ because its more secure. I managed it to create an IE and navigate to a site.</p>
  
  <p>But thats not what I need. I'm creating an instance of the IE in AutoIt and the part written in C++ has to connect to this IE and navigate to a specific page.</p>
  
  <p>Right now its an C++ Application but later on, when everything runs fine, I will create a .Dll out of it and call it with AutoIt. So I can pass values like hWnd and so on.</p>
  
  <p>I want to do this with good cause so please do not ask me why I am doing this. </p>
  
  <p>Does anybody know how I can manage it? Thanks in advance.</p>
  
  <pre><code>    CoInitialize(NULL);
  IWebBrowser2* pBrowser = NULL;
  HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL, 
      CLSCTX_SERVER, IID_IWebBrowser2, (LPVOID*)&amp;pBrowser);
  
  if (SUCCEEDED(hr) &amp;&amp; (pBrowser != NULL))
  {
      VARIANT vEmpty;
      VariantInit(&amp;vEmpty);
  
      VARIANT vFlags;
      V_VT(&amp;vFlags) = VT_I4;
      V_I4(&amp;vFlags) = navOpenInNewWindow;
  
      BSTR bstrURL = SysAllocString(L"http://www.ard.de");
  
      pBrowser-&gt;Navigate(bstrURL, &amp;vFlags, &amp;vEmpty, &amp;vEmpty, &amp;vEmpty);
      pBrowser-&gt;Quit();
  
      SysFreeString(bstrURL);
  }
  if (pBrowser)
      pBrowser-&gt;Release();
  CoUninitialize();
  return 0;
  </code></pre>