vbs

关注公众号 jb51net

关闭
首页 > 脚本专栏 > vbs >

VBS教程:属性-DriveType 属性

作者:

VBS教程:属性-DriveType 属性

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 & ": - " & t
End Function
阅读全文