Share via


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 Professional、Windows XP [デスクトップ アプリのみ]
サポートされている最小のサーバー
Windows 2000 Server [デスクトップ アプリのみ]
ヘッダー
Shldisp.h
IDL
Shldisp.idl
[DLL]
Shell32.dll (バージョン 4.71 以降)