Visual C++ FAQ

Как узнать тип диска? - часть 3

switch (uType) { case DRIVE_REMOTE: // GetDriveType() reports CD-ROMs as Remote drives. Need -7395------------------------------------------------------------------------ // to see if the drive is a CD-ROM or a network drive. if (IsCDRomDrive (nDrive)) { return (EX_DRIVE_CDROM | EX_DRIVE_NOACCESS); } else { return (EX_DRIVE_REMOTE | EX_DRIVE_NOACCESS); } break;

case DRIVE_REMOVABLE: // Check for a floppy disk drive. If it isn't, then we // don't know what kind of removable media it is. // For example, could be a Bernoulli box or something new... if (GetDeviceParameters (nDrive, &dp)) switch (dp.bDevType) { // Floppy disk drive types case 0x0: case 0x1: // 5.25" floppy case 0x3: case 0x4: // 8" floppy return (EX_DRIVE_FLOPPY5); case 0x2: case 0x7: case 0x8: // 3.5" floppy return (EX_DRIVE_FLOPPY3); } return (EX_DRIVE_REMOVABLE); // Unknown removable media type break;

case DRIVE_FIXED: __asm { xor dx,dx mov bx,nDrive inc bl // 1-'A', 2-'B',... mov ax,0x4409 call far ptr DOS3Call mov Drv4409Flag,dx } if (Drv4409Flag & 0x0100) fAddFlags |= EX_DRIVE_NOACCESS ; // GetDeviceParameters returns a device type of 0x05 for // hard disks. Because hard disks and RAM disks are the two // types of fixed-media drives, we assume that any fixed- // media drive that isn't a hard disk is a RAM disk. if (GetDeviceParameters (nDrive, &dp) && dp.bDevType == 0x05) { if (Drv4409Flag & 0x8000) return (EX_DRIVE_SUBSTED | fAddFlags); else return (EX_DRIVE_FIXED | fAddFlags); } else { return (EX_DRIVE_RAMDISK | fAddFlags); } break; } return (EX_DRIVE_INVALID); // Drive is invalid if we get here. }

Содержание  Назад  Вперед