'引用 Microsoft Scripting Runtime
Dim x As New Scripting.FileSystemObject
'Dim y As Scripting.Drive
Dim sMsg As String
sMsg = "CD-ROM "
Dim i As Integer
For i = Asc("C") To x.Drives.Count + Asc("C") - 2
If x.Drives.Item(Chr(i)).DriveType = CDRom Then
sMsg = "CD-ROM " & x.Drives.Item(Chr(i)).DriveLetter
Debug.Print "IsReady: " & x.Drives.Item(Chr(i)).IsReady
If x.Drives.Item(Chr(i)).IsReady Then
sMsg = sMsg & " 有 Disc - " & x.Drives.Item(Chr(i)).VolumeName
Debug.Print x.Drives.Item(Chr(i)).FileSystem
Else
sMsg = sMsg & " 无 Disc"
End If
MsgBox sMsg
End If
Next i
Dim x As New Scripting.FileSystemObject
'Dim y As Scripting.Drive
Dim sMsg As String
sMsg = "CD-ROM "
Dim i As Integer
For i = Asc("C") To x.Drives.Count + Asc("C") - 2
If x.Drives.Item(Chr(i)).DriveType = CDRom Then
sMsg = "CD-ROM " & x.Drives.Item(Chr(i)).DriveLetter
Debug.Print "IsReady: " & x.Drives.Item(Chr(i)).IsReady
If x.Drives.Item(Chr(i)).IsReady Then
sMsg = sMsg & " 有 Disc - " & x.Drives.Item(Chr(i)).VolumeName
Debug.Print x.Drives.Item(Chr(i)).FileSystem
Else
sMsg = sMsg & " 无 Disc"
End If
MsgBox sMsg
End If
Next i
解决方案 »
- 假设一个产品状态实时显示系统的问题
- vb+sqlserver数据备份与数据恢复的问题
- VB 调用 存储过程 sp_xml_preparedocument 为什么老失败
- 为什么我在vb中执行了Shell "ping www.sina.com >c:\IP.txt"以后,在C盘根目录下是空的或找不到IP.txt文件
- 如何将JPG图片转化为BMP图片
- 请问如何给计算机发送一个单击鼠标右键的消息?,谢谢!
- 增分!PowerDesigner
- MDI窗体中的“窗口”菜单中的“当前打开窗口列表”的问题
- 这个在查询分析器中执行正确的语句,它的SQL查询语句在VB中如何写?
- DeleteMenu 和 RemoveMenu 的区别
- 请懂得DirectX的高手进来
- Why?Why?Why!!!为什么没有敢回答我的问题!!!
'=================================================================
Option ExplicitPublic Const DRIVE_CDROM = 5
Public Const DRIVE_FIXED = 3
Public Const DRIVE_RAMDISK = 6
Public Const DRIVE_REMOTE = 4
Public Const DRIVE_REMOVABLE = 2
Public Const DRIVE_UNKNOWN = 0Private Declare Function GetDriveTypeA Lib "kernel32" (ByVal nDrive As String) As Long
Public Function sDriveType(sDrive As String) As String
Dim lRet As Long lRet = GetDriveTypeA(sDrive & ":\")
Select Case lRet
Case 0
sDriveType = "Unknown"
Case 1
sDriveType = "Unknown"
Case DRIVE_CDROM:
sDriveType = "CD-ROM Drive"
Case DRIVE_REMOVABLE:
sDriveType = "Removable Drive"
Case DRIVE_FIXED:
sDriveType = "Fixed Drive"
Case DRIVE_REMOTE:
sDriveType = "Remote Drive"
End Select
End FunctionPublic Function GetDriveType(sDrive As String) As Long
Dim lRet As Long
lRet = GetDriveTypeA(sDrive & ":\")
If lRet = 1 Then
lRet = 0
End If GetDriveType = lRet
End Function
'取得光驱的盘符
Function GetCDROMDrive() As String
Dim i As Integer
For i = 97 To 122
If GetDriveType(Chr(i)) = DRIVE_CDROM Then
GetCDROMDrive = Chr(i)
Exit Function
End If
Next
End Function