IShellDispatch.Windows method

Creates and returns a ShellWindows object. This object represents a collection of all of the open windows that belong to the Shell.

Syntax

retVal = IShellDispatch.Windows()

IShellDispatch.Windows() As IDispatch

Parameters

This method has no parameters.

Return value

JScript

Type: IDispatch**

An object reference to the ShellWindows object.

VB

Type: IDispatch**

An object reference to the ShellWindows object.

Remarks

This method is implemented and accessed through the Shell.Windows method.

Examples

The following examples use Windows to retrieve the ShellWindows object and display a count of the number of items that it contains. Usage is shown for JScript, VBScript, and Visual Basic.

JScript:

<script language="JScript">
    function fnShellWindowsJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var objShellWindows;
        
        objShellWindows = objshell.Windows();

        if (objShellWindows != null)
        {
            alert(objShellWindows.Count);
        }
    }
</script>

VBScript:

<script language="VBScript">
    function fnShellWindowsVB()
        dim objShell
        dim objShellWindows
        
        set objShell = CreateObject("shell.application")
        set objShellWindows = objshell.Windows

        if (not objShellWindows is nothing) then
            alert(objShellWindows.Count)
        end if

        set objShellWindows = nothing
        set objShell = nothing
    end function
 </script>

Visual Basic:

Private Sub fnShellWindowsVB()
    Dim objShell        As Shell
    Dim objShellWindows As ShellWindows
    
    Set objShell = New Shell
    Set objShellWindows = objshell.Windows

    If (Not objShellWindows Is Nothing) Then
        Debug.Print objShellWindows.Count
    End If

    Set objShellWindows = Nothing
    Set objShell = Nothing
End Sub

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Shldisp.h
IDL
Shldisp.idl
DLL
Shell32.dll (version 4.71 or later)