共用方式為


Folder.ParseName 方法

建立並傳回代表指定之專案的 FolderItem 物件。

語法

retVal = Folder.ParseName(
  bName
)

參數

bName [in]

類型: BSTR

指定專案名稱的字串。

傳回值

類型: FolderItem**

FolderItem物件的物件參考。

備註

ParseName 不應該用於虛擬資料夾,例如我的檔。

範例

下列範例使用 ParseName 建立物件,代表 C:\Windows 資料夾中的資料夾專案Clock.avi。 JScript、VBScript 和 Visual Basic 會顯示適當的使用方式。

Jscript:

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

VBScript:

<script language="VBScript">
    function fnFolderObjectParseNameVB()
        dim objShell
        dim objFolder
        
        set objShell = CreateObject("shell.application")
        set objFolder = objShell.NameSpace("C:\WINDOWS")

        if (not objFolder is nothing) then
            dim objFolderItem
            
            set objFolderItem = objFolder.ParseName("clock.avi")

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

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

Visual Basic:

Private Sub btnParseName_Click()
    Dim objShell  As Shell
    Dim objFolder As Folder

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

    If (Not objFolder Is Nothing) Then
        Dim objFolderItem As FolderItem
        
        Set objFolderItem = objFolder.ParseName("clock.avi")
            'Add code here.
            Debug.Print "passed"
        Set objFolderItem = Nothing
    End If

    Set objFolder = Nothing
    Set objShell = Nothing
End Sub

規格需求

需求
最低支援的用戶端
Windows 2000 專業版、Windows XP [僅限傳統型應用程式]
最低支援的伺服器
Windows 2000 Server [僅限傳統型應用程式]
標頭
Shldisp.h
Idl
Shldisp.idl
DLL
Shell32.dll (4.71 版或更新版本)