Find removable, fixed, CD-ROM, RAM disk, and network drives available on the local system.
See also:
- Disconnecting USB Mass Storage Device programmatically
- Mapping and disconnecting network drives in FoxPro application
- Enumerating network resources
- Enumerating Volumes and Volume Mounting Points (NTFS)
- Disk in drive A:
- How to detect when a removable drive gets connected or disconnected
DECLARE INTEGER GetLogicalDrives IN kernel32
DECLARE INTEGER GetDriveType IN kernel32 STRING nDrive
LOCAL nDrivesMask, nIndex, nShift, cDrive
nDrivesMask = GetLogicalDrives()
? "Available disk drives:"
nIndex = 0
DO WHILE .T.
nShift = BitLShift(1, nIndex)
cDrive = Chr(nIndex + 65) + ":"
IF BitAnd(nDrivesMask, nShift) = nShift
? cDrive, GetDriveType(cDrive)
ENDIF
IF nShift > nDrivesMask
EXIT
ENDIF
nIndex = nIndex + 1
ENDDO
DriveType:
0 Unknown
1 No Root Directory
2 Removable Disk
3 Local Disk
4 Network Drive
5 Compact Disc
6 RAM Disk
1 No Root Directory
2 Removable Disk
3 Local Disk
4 Network Drive
5 Compact Disc
6 RAM Disk
Related VFP functions: DRIVETYPE(), SYS(5), DISKSPACE().