Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 1.45 KB

sample_013.md

File metadata and controls

70 lines (50 loc) · 1.45 KB

主页

检索可用磁盘驱动器的列表

翻译:xinjie 2021.01.01

开始之前:

查找本地系统上可用的可移动、固定、CD-ROM、RAM磁盘和网络驱动器。

参考:


代码:

DECLARE INTEGER GetLogicalDrives IN kernel32
DECLARE INTEGER GetDriveType IN kernel32 STRING nDrive

LOCAL nDrivesMask, nIndex, nShift, cDrive
nDrivesMask = GetLogicalDrives()

? "可用磁盘驱动器:"

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  

函数列表:

GetDriveType
GetLogicalDrives

备注:

驱动器类型:

0 未知   
1 无 Root 目录   
2 可移动磁盘   
3 本地磁盘   
4 网络驱动器   
5 光盘   
6 RAM 磁盘

相关的VFP函数:DRIVETYPE(), SYS(5), DISKSPACE()。