FolderItems.Item 方法
检索集合中指定项的 FolderItem 对象。
语法
FolderItems.Item(
[ iIndex ]
)
参数
-
iIndex [in, optional]
-
类型: Variant
要检索的项的从零开始的索引。 此值必须小于 Count 属性的值。
返回值
对 FolderItem 对象的对象引用。
示例
以下示例使用 Item 检索 FolderItem 对象,该对象表示在 Windows 文件夹中找到的Notepad.exe文件。 显示 JScript、VBScript 和 Visual Basic 的正确用法。
Jscript:
<script language="JScript">
function fnFolderItemsItemJ()
{
var objShell = new ActiveXObject("shell.application");
var objFolder;
var ssfWINDOWS = 36;
objFolder = objShell.NameSpace(ssfWINDOWS);
if (objFolder != null)
{
var objFolderItems;
objFolderItems = objFolder.Items();
if (objFolderItems != null)
{
var objFolderItem;
objFolderItem = objFolderItems.Item(objFolderItems.Count - 1);
alert(objFolderItem.Name);
}
}
}
</script>
VBScript:
<script language="VBScript">
function fnFolderItemsItemVB()
dim objShell
set objShell = CreateObject("shell.application")
if (not objShell is nothing) then
dim objFolder
dim ssfWINDOWS
ssfWINDOWS = 36
set objFolder = objShell.NameSpace(ssfWINDOWS)
if (not objFolder is nothing) then
dim objFolderItems
set objFolderItems = objFolder.Items()
if (not objFolderItems is nothing) then
dim objFolderItem
set objFolderItem = objFolderItems.Item
if (not objFolderItem is nothing) then
alert(objFolderItem.Name)
end if
set objFolderItem = nothing
end if
set objFolderItems = nothing
end if
set objFolder = nothing
end if
set objShell = nothing
end function
</script>
Visual Basic:
Private Sub fnFolderItemsItemVB()
Dim objShell As Shell
Dim objFolder As Folder
Dim ssfWINDOWS As Long
ssfWINDOWS = 36
Set objShell = New Shell
Set objFolder = objShell.NameSpace(ssfWINDOWS)
If (Not objFolder Is Nothing) Then
Dim objFolderItems As FolderItems
Set objFolderItems = objFolder.Items
If (Not objFolderItems Is Nothing) Then
Dim objFolderItem As FolderItem
Set objFolderItem = objFolderItems.Item("NOTEPAD.EXE")
If (Not objFolderItem Is Nothing) Then
Debug.Print objFolderItem.Path
End If
Set objFolderItem = Nothing
End If
Set objFolderItems = Nothing
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
要求
要求 | 值 |
---|---|
最低受支持的客户端 |
Windows 2000 专业版、Windows XP [仅限桌面应用] |
最低受支持的服务器 |
Windows 2000 Server [仅限桌面应用] |
标头 |
|
IDL |
|
DLL |
|
另请参阅