VC中怎样得到系统的光驱的盘符?

解决方案 »

  1.   

    DWORD dwDrivesOnSystem = GetLogicalDrives();
    UCHAR rootpath[4] = "X:\\\0";
    char driveLabel;
    dwDrivesOnSystem >>= 3;//Skip A,B,C drive
    for (driveLabel = char('D'); driveLabel <= 'Z' && dwDrivesOnSystem > 0; driveLabel++, dwDrivesOnSystem >>= 1) {
        rootpath[0] = driveLabel;
        if( (dwDrivesOnSystem & 1 ) && (GetDriveType(rootpath) == DRIVE_CDROM))
        {
             //This drive is CDROM
        }
    }
      

  2.   

    GetDriveType();
    这在以前Crack软件时常要拦的函数:)