VB Code:
  1. Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  2. Private Const DRIVE_UNKNOWN = 0
  3. Private Const DRIVE_DOES_NOT_EXIST = 1
  4. Private Const DRIVE_REMOVABLE = 2
  5. Private Const DRIVE_FIXED = 3
  6. Private Const DRIVE_REMOTE = 4
  7. Private Const DRIVE_CDROM = 5
  8. Private Const DRIVE_RAMDISK = 6
  9.  
  10. Private Sub Form_Load()
  11. Select Case GetDriveType("C:\")
  12. Case DRIVE_UNKNOWN
  13. MsgBox "Unknown drive type", vbExclamation
  14. Case DRIVE_DOES_NOT_EXIST
  15. MsgBox "Drive doesn't exist", vbCritical
  16. Case DRIVE_REMOVABLE
  17. MsgBox "The disk can be removed from the drive", vbInformation
  18. Case DRIVE_FIXED
  19. MsgBox "The disk cannot be removed from the drive", vbInformation
  20. Case DRIVE_REMOTE
  21. MsgBox "The drive is a remote (network) drive", vbInformation
  22. Case DRIVE_CDROM
  23. MsgBox "The drive is a CD-ROM drive", vbInformation
  24. Case DRIVE_RAMDISK
  25. MsgBox "The drive is a RAM disk", vbInformation
  26. End Select
  27. End
  28. End Sub