VBS教程:属性-DriveType 属性

(编辑:jimmy 日期: 2024/12/23 浏览:2)

DriveType 属性

返回一个描述指定驱动器的类型的值。

object.DriveType

object 应为 Drive 对象的名称。

说明

以下代码举例说明如何使用 DriveType 属性:

Function ShowDriveType(drvpath)    Dim fso, d, t    Set fso = CreateObject("Scripting.FileSystemObject")    Set d = fso.GetDrive(drvpath)    Select Case d.DriveType        Case 0: t = "未知"        Case 1: t = "可移动"        Case 2: t = "固定"        Case 3: t = "网络"        Case 4: t = "CD-ROM"        Case 5: t = "RAM 磁盘"    End Select    ShowDriveType = "驱动器 " & d.DriveLetter & ": - " & tEnd Function