How to determine if drive is external drive

后端 未结 3 798
清歌不尽
清歌不尽 2020-12-17 02:05

How can I determine if a drive is a external drive plugged in through usb ? I checked the DriveInfo.DriveType but with my 1TB external drive plugged in through usb it shows

3条回答
  •  自闭症患者
    2020-12-17 02:29

    you can use WMI with

    Select * from Win32_LogicalDisk
    

    http://www.jpsoftwaretech.com/vba/using-wmi-services-in-vba/drive-information-local-network-mapped-drives/

    there you have

     Select Case .DriveType
            Case 0
              strDriveType = "Unknown"
            Case 1
              strDriveType = "No Root Directory"
            Case 2
              strDriveType = "Removable Disk"
            Case 3
              strDriveType = "Local Disk"
            Case 4
              strDriveType = "Network Drive"
            Case 5
              strDriveType = "Compact Disc"
            Case 6
              strDriveType = "RAM Disk"
          End Select
    

提交回复
热议问题