Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Get type of drive


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


'text a drive for its type
Function DriveType (DPath As String ) As String
'pass "C:\" or other drive path
Select Case GetDriveType(DPath)
            Case DRIVE_REMOVABLE:  DriveType =   "Removable"
            Case DRIVE_FIXED:  DriveType = "Fixed"
            Case DRIVE_REMOTE:  DriveType = "Remote"
            Case DRIVE_CDROM:  DriveType = "CDROM"
            Case DRIVE_RAMDISK:  DriveType = "RAM Disk"
End Select
End Sub