UINT GetDriveType(DriveNumber) | |||||
int DriveNumber; | /* 0 = A, 1 = B, and so on | */ |
The GetDriveType function determines whether a disk drive is removable, fixed, or remote.
DriveNumber
Specifies the drive for which the type is to be determined (0 = drive A, 1 = drive B, 2 = drive C, and so on).
The return value is DRIVE_REMOVABLE (disk can be removed from the drive), DRIVE_FIXED (disk cannot be removed from the drive), or DRIVE_REMOTE (drive is a remote, or network, drive), if the function is successful. Otherwise, the return value is zero.
The following example uses the GetDriveType function to determine the drive type for all possible disk drives (letters A through Z):
int iDrive;
WORD wReturn;
char szMsg[80];
for (iDrive = 0, wReturn = 0;
(iDrive < 26) && (wReturn != 1); iDrive++) {
wReturn = GetDriveType(iDrive);
sprintf(szMsg, "drive %c: ", iDrive + 'A');
switch (wReturn) {
case 0:
strcat(szMsg, "undetermined");
break;
case DRIVE_REMOVABLE:
strcat(szMsg, "removable");
break;
case DRIVE_FIXED:
strcat(szMsg, "fixed");
break;
case DRIVE_REMOTE:
strcat(szMsg, "remote (network)");
break;
}
TextOut(hdc, 10, 15 * iDrive, szMsg, strlen(szMsg));
}