Visual Basic > API and Miscellaneous
Use of the API-call to get drive information
Use of the API-call to get drive information Declare Function GetLogicalDriveStrings Lib "kernel32" alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Declare Function GetDriveType Lib "kernel32" alias "GetDriveTypeA" (ByVal nDrive As String) As Long Global Const DRIVE_REMOVABLE = 2 Global Const DRIVE_FIXED = 3 Global Const DRIVE_REMOTE = 4 Global Const DRIVE_CDROM = 5 Global Const DRIVE_RAMDISK = 6 Public Function GetAllDrives() As String Dim lngResult&, strDrives$, strJustOneDrive$, intPos%, lngDriveType& Dim strBuffer As String 'buffer op procedureniveau declareren. strDrives$ = Space$(255) lngResult& = GetLogicalDriveStrings(Len(strDrives$), strDrives$) strDrives$ = Left$(strDrives$, lngResult&) Do intPos% = InStr(strDrives$, Chr$(0)) If intPos% Then strJustOneDrive$ = Left$(strDrives$, intPos% - 1) strDrives$ = Right$(strDrives$, Len(strDrives$) - intPos%) lngDriveType& = GetDriveType(strJustOneDrive$) select case lngDriveType& case DRIVE_CDROM strBuffer = strBuffer & "CD-Rom: " & strJustOneDrive$ & vbCrLf case DRIVE_REMOVABLE strBuffer = strBuffer & "RemovableDrive: " & strJustOneDrive$ & vbCrLf case DRIVE_FIXED strBuffer = strBuffer & "LocalDrive: " & strJustOneDrive$ & vbCrLf case DRIVE_REMOTE strBuffer = strBuffer & "NetworkDrive: " & strJustOneDrive$ & vbCrLf case DRIVE_RAMDISK strBuffer = strBuffer & "RamDrive: " & strJustOneDrive$ & vbCrLf end Select end If loop Until strDrives$ = "" GetAllDrives = strBuffer End Function Return
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows