共用方式為


Folder2.Self 屬性

包含資料夾的 FolderItem 物件。

這個屬性是唯讀的。

Syntax

Self = Folder2.Self

屬性值

評估為資料夾 FolderItem 物件的 物件。

範例

下列範例使用 Self 來擷取 C:\Windows 資料夾的 FolderItem 。 JScript、VBScript 和 Visual Basic 會顯示適當的使用方式。

Jscript:

<script language="JScript">
    function fnFolder2ObjectSelfJ()
    {
        var objShell  = new ActiveXObject("shell.application");
        var objFolder2 = new Object;
        
        objFolder2 = objShell.NameSpace("C:\\WINDOWS");
        if (objFolder2 != null)
        {
            var objFolderItem = new Object;
            
            objFolderItem = objFolder2.Self;
            if (objFolderItem != null)
            {
                //Add code here.
            }
        }
    }
</script>

VBScript:

<script language="VBScript">
    function fnFolder2ObjectSelfVB()
        dim objShell
        dim objFolder2

        set objShell = CreateObject("shell.application")
        set objFolder2 = objShell.NameSpace("C:\WINDOWS")

        if (not objFolder2 is nothing) then
            dim objFolderItem
            
            set objFolderItem = objFolder2.Self

            if (not objFolderItem is nothing) then
                'Add code here.
            end if
        end if

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

Visual Basic:

Private Sub btnFolder2Self_Click()
    Dim objShell   As Shell
    Dim objFolder2 As Folder2

    Set objShell = New Shell
    Set objFolder2 = objShell.NameSpace("C:\WINDOWS")

    If (Not objFolder2 Is Nothing) Then
        Dim objFolderItem As FolderItem
        
        Set objFolderItem = objFolder2.Self()

        If (Not objFolderItem Is Nothing) Then
            'Add code here.
        End If

        Set objFolderItem = Nothing
    End If

    Set objFolder2 = Nothing
    Set objShell = Nothing
End Sub

規格需求

需求
最低支援的用戶端
Windows 2000 Professional、Windows XP [僅限桌面應用程式]
最低支援的伺服器
Windows Server 2003 [僅限桌面應用程式]
標頭
Shldisp.h
Idl
Shldisp.idl
DLL
Shell32.dll (5.0 版或更新版本)

另請參閱

Folder2

資料夾