The following example illustrates the use of the GetDriveType function.
' ########################################################################################
' The following example illustrates the use of the GetDriveType function.
' ########################################################################################
#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"
' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN () AS LONG
LOCAL dwBufLen AS DWORD
LOCAL strBuffer AS STRING
LOCAL nDrives aS LONG
LOCAL szDrive AS ASCIIZ * 4
LOCAL i AS LONG
' Retrieve the need buffer length
dwBufLen = GetLogicalDriveStrings(0, BYVAL %NULL)
' Prepare a long enough buffer
strBuffer = STRING$(dwBufLen, $NUL)
' Get the list of drives
GetLogicalDriveStrings(dwBufLen, BYVAL STRPTR(strBuffer))
' Trim the last two nuls
strBuffer = RTRIM$(strBuffer, $NUL)
' Retrieve the number of drives in the list
nDrives = PARSECOUNT(strBuffer, $NUL)
' Parse the list
FOR i = 1 TO nDrives
szDrive = PARSE$(strBuffer, $NUL, i)
SELECT CASE GetDriveType(szDrive)
CASE %DRIVE_FIXED : ? szDrive & " Type: Fixed"
CASE %DRIVE_REMOTE : ? szDrive & " Type: Remote"
CASE %DRIVE_REMOVABLE: ? szDrive & " Type: Removable"
CASE %DRIVE_CDROM : ? szDrive & " Type: CD-ROM"
CASE %DRIVE_RAMDISK : ? szDrive & " Type: RAMDISK"
CASE ELSE : ? szDrive & " Type: Unknown Type"
END SELECT
NEXT
#IF %DEF(%PB_CC32)
WAITKEY$
#ENDIF
END FUNCTION
' ========================================================================================