1 #include <iostream> 2 #include "classAh.h" 3 #include <atlstr.h> 4 using namespace std; 5 6 7 int main() 8 { 9 char rootPath[10] = {0}, driveType[21] = {0}; 10 UINT nType; 11 12 for(char a = ‘A‘; a <= ‘Z‘; a++) 13 { 14 sprintf(rootPath, "%c:\\", a); 15 nType = GetDriveType(rootPath); 16 if(nType != DRIVE_NO_ROOT_DIR) // DRIVE_NO_ROOT_DIR: 路径无效 17 { 18 switch(nType) 19 { 20 case DRIVE_FIXED: 21 strcpy(driveType, "硬盘"); 22 break; 23 case DRIVE_REMOVABLE: 24 strcpy(driveType, "移动硬盘"); 25 break; 26 case DRIVE_CDROM: 27 strcpy(driveType, "光盘"); 28 break; 29 case DRIVE_RAMDISK: 30 strcpy(driveType, "RAM盘"); 31 break; 32 case DRIVE_REMOTE: 33 strcpy(driveType, "Remote(Network) drive 网络磁盘"); 34 break; 35 case DRIVE_UNKNOWN: 36 default: 37 strcpy(driveType, "未知盘"); 38 break; 39 } 40 cout<<rootPath<<"\t"<<driveType<<endl; 41 } 42 } 43 44 getchar(); 45 return 0; 46 }
时间: 2024-10-05 03:04:29