??

解决方案 »

  1.   

    Option Explicit'¡¾ËµÃ÷¡¿
    ' ÅжÏϵͳÖдæÔÚÄÄЩÂß¼­Çý¶¯Æ÷×Öĸ
    '¡¾·µ»ØÖµ¡¿
    ' Long£¬Õâ¸ö½á¹¹ÖеĶþ½øÖÆλ±êÖ¾×Å´æÔÚÄÄЩÇý¶¯Æ÷¡£ÆäÖУ¬Î»0ÉèΪ1±íʾÇý¶¯Æ÷A:´æÔÚÓÚϵͳÖУ»Î»1ÉèΪ1±íʾ´æÔÚB:Çý¶¯Æ÷£»ÒÔ´ÎÀàÍÆ
    Private Declare Function GetLogicalDrives Lib "kernel32" () As LongPrivate Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As LongPrivate Sub Form_Load()
        'MsgBox CStr(GetLogicalDrives)
        D_To_B GetLogicalDrives
        GetDrvType
    End SubPublic Sub D_To_B(ByVal MyNum As Long)
        Dim H As Long
        Dim S As String
        
        H = MyNum
        
        Do While H > 0
            S = Str(H Mod 2) + Trim(S)
            H = H \ 2
            DoEvents
        Loop
        
        MsgBox S
    End SubPublic Sub GetDrvType()
        'Set the graphic mode to persistent
        Me.AutoRedraw = True
        'Get information about the C:\
        Select Case GetDriveType("i:\")
            Case 2
                Me.Print "Removable"
            Case 3
                Me.Print "Drive Fixed"
            Case Is = 4
                Me.Print "Remote"
            Case Is = 5
                Me.Print "Cd-Rom"
            Case Is = 6
                Me.Print "Ram disk"
            Case Else
                Me.Print "Unrecognized"
        End Select
    End Sub=======================
    或者使用下面的:
    Option ExplicitPrivate Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As LongPrivate Sub Command1_Click()
        If Trim(Text1.Text) = "" Then Exit Sub
            
        Dim Serial As Long, VName As String, FSName As String
        'Create buffers
        VName = String$(255, Chr$(0))
        FSName = String$(255, Chr$(0))
        'Get the volume information
        GetVolumeInformation Trim(Text1.Text), VName, 255, Serial, 0, 0, FSName, 255
        'Strip the extra chr$(0)'s
        VName = Left$(VName, InStr(1, VName, Chr$(0)) - 1)
        FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) - 1)
        MsgBox "The Volume name is '" + VName + "', the File system name is '" + FSName + "' and the serial number is '" + Trim(Str$(Serial)) + "'", vbInformation + vbOKOnly, App.TitleEnd Sub得到了磁盘格式自然就知道是什么盘了
      

  2.   


        如何判断某一个Drive是否为光碟机? 
     
     
    须 调 用 Windows API 的 GetDriveType ,首先 声 明 以 下 API :
    Declare Function GetDriveType Lib "kernel32" Alias _
    "GetDriveTypeA" (ByVal nDrive As String) As Long
    然后将以上的声明放在.bas的一般模块中,如果放在 Form 之中, 须在Declare之前再加上 Private。 然后使用以下叙述调用 :
    ret = GetDriveType ( "D:\")
    若传回值 ret 等于 5 , 即表示 "D:\" 为光碟机 , 至于其他传回值的意义则是 :
    2:软碟, 3:硬碟, 4:Server端磁碟, 6:RAMDISK。