DriveType – Determine the type of a drive

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _    (ByVal lpRootPathName As String) As LongConst DRIVE_UNKNOWN = 0      ' type can't be determinedConst DRIVE_NO_ROOT_DIR = 1  ' wrong argumentConst DRIVE_REMOVABLE = 2Const DRIVE_FIXED = 3Const DRIVE_REMOTE = 4Const DRIVE_CDROM = 5Const DRIVE_RAMDISK = 6' Determine the type of a drive. If you pass a null string it returns' the type of the current drive'' Returns one of the DRIVE_* constants, and stores in the optional' DriveDescription argument a textual description of the resultFunction DriveType(ByVal DriveName As String, Optional DriveDescription As _    String) As Long    If Len(DriveName) = 0 Then        ' use NULL if a null string has been passed (default drive)        DriveName = vbNullString    Else        ' otherwise always provide a colon and backslash        DriveName = Left$(DriveName, 1) & ":"    End If        DriveType = GetDriveType(DriveName)    Select Case DriveType        Case DRIVE_UNKNOWN            DriveDescription = "(unknown)"        Case DRIVE_REMOVABLE            DriveDescription = "Removable Drive"        Case DRIVE_FIXED            DriveDescription = "Fixed Drive"        Case DRIVE_REMOTE            DriveDescription = "Remote Drive"        Case DRIVE_CDROM            DriveDescription = "CD-ROM"        Case DRIVE_RAMDISK            DriveDescription = "RAM Disk"        Case Else            ' this includes the DRIVE_NO_ROOT_DIR case            DriveDescription = ""    End SelectEnd Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS