ShellWindows object
Applies to: desktop apps only
Represents a collection of the open windows that belong to the Shell. Methods associated with this objects can control and execute commands within the Shell, and obtain other Shell-related objects.
Members
The ShellWindows object has these types of members:
Methods
The ShellWindows object has these methods.
| Method | Description |
|---|---|
| _NewEnum |
Creates and returns a new ShellWindows object that is a copy of this ShellWindows object. |
| Item |
Retrieves an InternetExplorer object that represents the Shell window. |
Properties
The ShellWindows object has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only |
Contains the number of items in the collection. |
Requirements
|
Minimum supported client | Windows 2000 Professional, Windows XP |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
DLL |
|
Send comments about this topic to Microsoft
Build date: 3/7/2012
Find all running instances of IE and get web page Url
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
...
public static class IEHelper
{
public static IEnumerable<dynamic> FindAll()
{
var t = Type.GetTypeFromProgID("Shell.Application");
dynamic o = Activator.CreateInstance(t);
try
{
var ws = o.Windows();
for (int i = 0; i < ws.Count; i++)
{
var ie = ws.Item(i);
if (ie == null) continue;
var path = System.IO.Path.GetFileName((string)ie.FullName);
if(path == "iexplore.exe")
yield return ie;
}
}
finally
{
Marshal.FinalReleaseComObject(o);
}
}
}
// test
foreach (var ie in IEHelper.FindAll())
{
var url = (string) ie.Document.location.href;
System.Diagnostics.Trace.WriteLine(url);
}
Find all running instances of IE and get web page Url
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
...
public static class IEHelper
{
public static IEnumerable<dynamic> FindAll()
{
var t = Type.GetTypeFromProgID("Shell.Application");
dynamic o = Activator.CreateInstance(t);
try
{
var ws = o.Windows();
for (int i = 0; i < ws.Count; i++)
{
var ie = ws.Item(i);
if (ie == null) continue;
var path = System.IO.Path.GetFileName((string)ie.FullName);
if(path == "iexplore.exe")
yield return ie;
}
}
finally
{
Marshal.FinalReleaseComObject(o);
}
}
}
// test
foreach (var ie in IEHelper.FindAll())
{
var url = (string) ie.Document.location.href;
System.Diagnostics.Trace.WriteLine(url);
}