共用方式為


IShellDispatch.Windows 方法

建立並傳回 ShellWindows 物件。 這個 物件代表屬於 Shell 之所有開啟視窗的集合。

語法

retVal = IShellDispatch.Windows()

IShellDispatch.Windows() As IDispatch

參數

這個方法沒有任何參數。

傳回值

JScript

類型: IDispatch**

ShellWindows物件的物件參考。

VB

類型: IDispatch**

ShellWindows物件的物件參考。

備註

此方法是透過 Shell.Windows 方法實作和存取。

範例

下列範例會使用 Windows 來擷取 ShellWindows 物件,並顯示其包含的專案數計數。 JScript、VBScript 和 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

規格需求

需求
最低支援的用戶端
Windows 2000 專業版、Windows XP [僅限傳統型應用程式]
最低支援的伺服器
Windows 2000 Server [僅限傳統型應用程式]
標頭
Shldisp.h
Idl
Shldisp.idl
DLL
Shell32.dll (4.71 版或更新版本)