Skip to content

Instantly share code, notes, and snippets.

@billagee
Last active August 20, 2016 17:36
Show Gist options
  • Save billagee/2267093 to your computer and use it in GitHub Desktop.
Save billagee/2267093 to your computer and use it in GitHub Desktop.
VS 2008 example of using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
// Using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
//
// VS 2008 edition!
//
// To do this you must add a reference to the COM component
// named "Microsoft Internet Controls" (AKA SHDocVw)
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
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