ShellWindows.Count 属性

包含集合中的项数。

此属性为只读。

语法

iCount = ShellWindows.Count

属性值

包含 Count 属性的值的 Integer

示例

以下示例显示 正在使用的 Count 。 显示 JScript、VBScript 和 Visual Basic 的正确用法。

Jscript:

<script language="JScript">
    function fnShellWindowsCountJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var objShellWindows;
        
        objShellWindows = objshell.Shell_Windows();
        if (objShellWindows != null)
        {
            var nCount;
            
            nCount = objShellWindows.Count;
            alert(nCount);
        }
    }
</script>

VBScript:

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

        if (not objShellWindows is nothing) then
            dim nCount
            nCount = objShellWindows.Count

            alert(nCount)
        end if

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

Visual Basic:

Private Sub fnShellWindowsCountVB()
    Dim objShell         As Shell
    Dim objShellWindows  As ShellWindows
    
    Set objShell = New Shell
    Set objShellWindows = objshell.Shell_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 [仅限桌面应用]
标头
Exdisp.h
DLL
Shell32.dll (4.71 或更高版本)