您现在的位置是:网站首页> 编程资料编程资料
VBS教程:对象-Drives 集合_vbs_
2023-05-25
342人已围观
简介 VBS教程:对象-Drives 集合_vbs_
Drives 集合
只读所有可用驱动器的集合。
说明
无论是否插入媒体,可移动媒体驱动器都显示在 Drives 集合中。
以下代码举例说明如何获得 Drives 集合并使用 For Each...Next 语句枚举集合成员:
ShowDriveList函数Dim fso, d, dc, s, nSet fso = CreateObject("Scripting.FileSystemObject")Set dc = fso.DrivesFor Each d in dcn = ""s = s & d.DriveLetter & " - "If d.DriveType = Remote Thenn = d.ShareNameElseIf d.IsReady Thenn = d.VolumeNameEnd Ifs = s & n &"
"NextShowDriveList = sEnd Function
