DriveType()
This function reports the type of drive specified, reading only the first letter of the supplied parameter. It duplicates, with one exception, the DriveType() function of FoxTools, which itself is just a wrapper around the Win32 API function, GetDriveType().
Usage |
nType = DriveType( cDriveLetter ) |
Parameter |
Value |
Meaning |
cDrive |
A - Z |
The drive whose type is to be checked. |
nType |
0 |
Under VFP 3.x and 5.x, no such drive. |
1 |
In VFP 6.0 and later, no such drive. |
|
2 |
Floppy drive. |
|
3 |
Hard disk. |
|
4 |
Removable or network drive. |
|
5 |
CD-ROM. |
|
6 |
RAM disk. |
VFP 3.x and 5.x with FoxTools reports 0 for unknown drives. VFP 6.0 and later report 1 instead. |
And, of course, it doesn't always work. DriveType() doesn't work with UNC paths, returning 0 or 1 for an unknown drive. That's undoubtedly because the function looks only at the first letter of the string you pass it. |
Example |
* Returns 2 for most folks. ? DriveType("A") * This code provides the same functionality for VFP 3 or 5 * on any Win32 Platform. LPARAMETERS tcDrive DECLARE Integer GetDriveType ; IN WIN32API ; AS WGDT ; STRING DriveLetter RETURN WGDT(LEFT(tcDrive,1) + ":") * Z: is mapped as a ZIP drive on the network. ? DriveType("\\Orion\ZIPDrive") && 1: unknown ? DriveType("Z") && 4: removable/network drive * On the local machine, this drive displays type 2 - floppy. SET DEFAULT TO Z ? SYS(2020) && 100431872 - 95.8 Mb ? SYS(2022, "Z") && 2048 - 2K cluster size |
See Also |