VBS教程:屬性-IsReady 屬性

NO IMAGE

IsReady 屬性

如果指定的驅動器就緒,返回 True;否則返回 False

object.IsReady

object 應為 Drive 物件的名稱。

說明

對於可移動媒體驅動器和 CD-ROM 驅動器,僅當插入相應的媒體並準備接受訪問時,IsReady 返回 True

以下程式碼舉例說明如何使用 IsReady 屬性:

Function ShowDriveInfo(drvpath)    Dim fso, d, s, 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    s = "驅動器 " & d.DriveLetter & ": - " & t    If d.IsReady Then         s = s & "<BR>" & "驅動器已就緒。"    Else        s = s & "<BR>"  & "驅動器未就緒。"    End IfShowDriveInfo = sEnd Function