title: How to get the URL of the Internet explorer tabs with PID of each tab?
body: <p>I have my application which triggers Web Browser with specific URL .
  After my program ends i want to close the web pages/tabs which i have opened..</p>
  
  <p>By calling an EXE file with parameters a. Process Name b. String present in the URL</p>
  
  <p>Detailed problem
  <a href="https://stackoverflow.com/questions/8254379/how-to-kill-firefox-child-process-tab-from-java-c">How to kill firefox child process/tab from Java/C++</a></p>
  
  <p>I used C# approach ...</p>
  
  <p>I am able to find the process ID of all the tabs..</p>
  
  <pre><code>foreach (Process theprocess in processlist) {
      if (theprocess.ProcessName == "iexplore") {
          Console.WriteLine("Process: {0}\tID: {1}\tWindow name: {2}",
              theprocess.ProcessName, theprocess.Id, theprocess.MainWindowTitle
          );
      }
  }
  </code></pre>
  
  <p>Currently i can get only Window Title of the process....and in IE8 only one window title of main process is visible..</p>
  
  <p>Provided i have the pids of each tabs,How to find the URL of the tab ...and kill only that tab ?? </p>
  
  <p>I got this help from 
  <a href="https://stackoverflow.com/questions/3288092/access-is-denied-when-trying-to-get-the-url-text-from-address-bars-handle/8444478#8444478">Access is denied - when trying to get the url (text) from address bar&#39;s handle</a></p>
  
  <p>using SHDocVw;
  .
  .</p>
  
  <p>foreach (InternetExplorer ieInst in new ShellWindowsClass())
     Console.WriteLine(ieInst.LocationURL);</p>