Condividi tramite


Metodo ShellWindows.Item

Recupera un oggetto InternetExplorer che rappresenta la finestra della shell.

Sintassi

retVal = ShellWindows.Item(
  [ iIndex ]
)

Parametri

iIndex [in, facoltativo]

Tipo: Variant

Indice in base zero dell'elemento da recuperare. Questo valore deve essere minore del valore della proprietà Count . Se questo valore viene omesso, viene utilizzato un valore predefinito pari a 0.

Valore restituito

Tipo: IDispatch**

Riferimento all'oggetto InternetExplorer che rappresenta la finestra della shell.

Esempio

Nell'esempio seguente viene utilizzato Item per recuperare l'oggetto InternetExplorer che rappresenta il primo elemento della finestra della shell. Viene visualizzato un utilizzo appropriato per JScript, VBScript e Visual Basic.

Jscript:

<script language="JScript">
    function fnShellWindowsItemJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var objShellWindows;
        
        objShellWindows = objshell.Windows();
        if (objShellWindows != null)
        {
            var objIE;
            objIE = objShellWindows.Item();

            if (objIE != null)
            {
                alert(objIE.path());
            }
        }
    }
</script>

Vbscript:

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

        if (not objShellWindows is nothing) then
            dim objIE
            set objIE = objShellWindows.Item

            if (not objIE is nothing) then
                Wscript.Echo objIE.path
            end if

            set objIE = nothing
        end if

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

Visual Basic:

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

    If (Not objShellWindows Is Nothing) Then
        Dim objIE As InternetExplorer
        Set objIE = objShellWindows.Item

        If (Not objIE Is Nothing) Then
            Debug.Print objIE.Path
        End If

        Set objIE = Nothing
    End If

    Set objShellWindows = Nothing
    Set objShell = Nothing
End Sub

Requisiti

Requisito Valore
Client minimo supportato
Windows 2000 Professional, Windows XP [solo app desktop]
Server minimo supportato
Windows 2000 Server [solo app desktop]
Intestazione
Exdisp.h
DLL
Shell32.dll (versione 4.71 o successiva)