Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.5 KB

sample_013.md

File metadata and controls

65 lines (46 loc) · 1.5 KB

Home

Retrieving list of available disk drives

Before you begin:

Find removable, fixed, CD-ROM, RAM disk, and network drives available on the local system.

See also:


Code:

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  

Listed functions:

GetDriveType
GetLogicalDrives

Comment:

DriveType:

0 Unknown
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().