VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Drive Type Finder

by Super--s (1 Submission)
Category: Coding Standards
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This code will loop through all drives and determine what type it is(hard disk, floppy, CDROM, network, etc)

API Declarations
Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Public Const DRIVE_CDROM = 5
Public Const DRIVE_FIXED = 3
Public Const DRIVE_RAMDISK = 6
Public Const DRIVE_REMOTE = 4
Public Const DRIVE_REMOVABLE = 2

Rate Drive Type Finder

Dim strDrive As String
Dim strMessage As String
Dim intCnt As Integer
For intCnt = 65 To 86
  strDrive = Chr(intCnt)
  Select Case GetDriveType(strDrive + ":\")
      Case DRIVE_REMOVABLE
        rtn = "Floppy Drive"
      Case DRIVE_FIXED
        rtn = "Hard Drive"
      Case DRIVE_REMOTE
        rtn = "Network Drive"
      Case DRIVE_CDROM
        rtn = "CD-ROM Drive"
      Case DRIVE_RAMDISK
        rtn = "RAM Disk"
      Case Else
        rtn = ""
  End Select
  If rtn <> "" Then
    strMessage = strMessage & vbCrLf & "Drive " & strDrive & " is type: " & rtn
  End If
Next intCnt
MsgBox (strMessage)

Download this snippet    Add to My Saved Code

Drive Type Finder Comments

No comments have been posted about Drive Type Finder. Why not be the first to post a comment about Drive Type Finder.

Post your comment

Subject:
Message:
0/1000 characters