Skip to content

Instantly share code, notes, and snippets.

@billagee
Last active August 20, 2016 17:36
Show Gist options
  • Save billagee/46a1ea83b59f13146567cb779dd003b0 to your computer and use it in GitHub Desktop.
Save billagee/46a1ea83b59f13146567cb779dd003b0 to your computer and use it in GitHub Desktop.
VS 2012 example of using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
// Using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
//
// VS 2012 edition!
//
// To do this you must add a reference to the COM component
// named "Microsoft Internet Controls" (AKA SHDocVw)
using SHDocVw;
// ... snip boilerplate code ...
SHDocVw.ShellWindows shellWindows = new ShellWindows();
foreach (SHDocVw.IWebBrowser2 ie in shellWindows)
{
Console.WriteLine("ie.LocationURL: " + ie.LocationURL);
if (ie.LocationURL.Contains("foo.com"))
ie.Quit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment