Επεξεργασία

Κοινή χρήση μέσω


ShellWindows.Item method

Retrieves an InternetExplorer object that represents the Shell window.

Syntax

retVal = ShellWindows.Item(
  [ iIndex ]
)

Parameters

iIndex [in, optional]

Type: Variant

The zero-based index of the item to retrieve. This value must be less than the value of the Count property. If this value is omitted, a default value of 0 is used.

Return value

Type: IDispatch**

An object reference to the InternetExplorer object that represents the Shell window.

Examples

The following example uses Item to retrieve the InternetExplorer object that represents the first Shell window item. Proper usage is shown for JScript, VBScript, and 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

Requirements

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