例如机器上有三个光驱:
E--放CD
F--放VCD
G-放DVD
怎么获得E、F、G盘,并能获得光驱里光盘的类型

解决方案 »

  1.   

    用下面的代码可以获得所有的光驱,但怎么区分是VCD,CD,DVD?它有什么不同?读文件?文件夹?Private Function getDriveType(intDriveType) As String
        Select Case intDriveType
            Case 0: getDriveType = "Unknown"
            Case 1: getDriveType = "Removable"
            Case 2: getDriveType = "Fixed"
            Case 3: getDriveType = "Network"
            Case 4: getDriveType = "CD-ROM"
            Case 5: getDriveType = "RAM Disk"
        End Select
    End FunctionPrivate Sub Command2_Click()
        Dim x As New Scripting.FileSystemObject
        Dim y As Scripting.Drive
        For Each y In x.Drives
            MsgBox getDriveType(y.DriveType)
        Next
    End Sub
      

  2.   

    参考:http://codeguru.com/misc/CdChange.shtml
    http://codeguru.com/misc/cdEject.html
      

  3.   

    看不懂VC,rainstormmaster给我说说思路,是不是只能读文件来区分光碟类型
      

  4.   

    有两个光驱的帮我测试一下啊Dim a() As String
    Dim b() As IntegerPrivate Function CheckCD(ByRef Disks() As String, ByRef CDType() As Integer) As Integer
        Dim fso As New Scripting.FileSystemObject
        Dim dri As Scripting.Drive
        Dim i As Integer
        CheckCD = 0
        i = 0
        On Error GoTo ErrHandler
        For Each dri In fso.Drives
            '判断是否是CD-ROM
            If dri.DriveType = 4 Then
                i = i + 1
                ReDim Disks(i) As String
                ReDim CDType(i) As Integer
                If Dir(dri.Path & "\*.CDA") <> "" Then
                    'CD
                    Disks(i) = dri.Path
                    CDType(i) = 1
                    CheckCD = 1
                ElseIf Dir(dri.Path & "\MPEGAV", vbDirectory) <> "" Then
                    'VCD
                    Disks(i) = dri.Path
                    CDType(i) = 2
                    CheckCD = 1
                ElseIf Dir(dri.Path & "\VIDEO_TS", vbDirectory) <> "" And Dir(dri.Path & "\VIDEO_TS", vbDirectory) <> "" Then
                    'DVD
                    Disks(i) = dri.Path
                    CDType(i) = 3
                    CheckCD = 1
                End If
            End If
        Next
        Exit Function
    ErrHandler:
        CheckCD = 0
    End FunctionPrivate Sub Command1_Click()
        Dim i As Integer
        If CheckCD(a(), b()) Then
            For i = 1 To UBound(a)
                MsgBox a(i) & b(i)
            Next i
        End If
    End Sub
      

  5.   

    //看不懂VC,rainstormmaster给我说说思路,是不是只能读文件来区分光碟类型上面给的我也没细看,不过建议你用NeroCom.dll实现(NeroCom.dll是一个activex dll),它提供了一个NeroCDInfo类,这个类的MediaType属性返回的就是光盘的类型,至于具体的实现,你自己查找一下资料吧