这是一个很棘手的问题。
一般是通过磁盘的属性来判断的,但是这个是不准的,有很多移动存储设备的磁盘属性,就是和本地磁盘一样的。
后来又想到通过盘符的顺序,认为光驱盘符之后的磁盘就是移动存储设备,这也是不准的,很多时候,移动存储设备插入后,盘符会在光驱盘符之前出现。到底怎样才能准确无误的来判断呢?

解决方案 »

  1.   

    DiskType=GetDriveType(strTempDirver);
           switch(DiskType) 
       {
          case DRIVE_NO_ROOT_DIR:
           return;
          case DRIVE_REMOVABLE:
           //::AfxMessageBox(DriveName);
           break;
          case DRIVE_FIXED:
           //::AfxMessageBox("固定硬盘驱动器");
           break;
          case DRIVE_REMOTE:
           //::AfxMessageBox("这是网络驱动器");
           return;
          case DRIVE_CDROM:
           //::AfxMessageBox("这是光盘驱动器");
           return;
      

  2.   

    GetDriveTypeThe GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. 
    UINT GetDriveType(
      LPCTSTR lpRootPathName
    );Parameters
    lpRootPathName 
    [in] Pointer to a null-terminated string that specifies the root directory of the disk to return information about. A trailing backslash is required. If this parameter is NULL, the function uses the root of the current directory. 
    Return Values
    The return value specifies the type of drive. It can be one of the following values.Value Meaning 
    DRIVE_UNKNOWN The drive type cannot be determined. 
    DRIVE_NO_ROOT_DIR The root path is invalid. For example, no volume is mounted at the path. 
    DRIVE_REMOVABLE The disk can be removed from the drive. 
    DRIVE_FIXED The disk cannot be removed from the drive. 
    DRIVE_REMOTE The drive is a remote (network) drive. 
    DRIVE_CDROM The drive is a CD-ROM drive. 
    DRIVE_RAMDISK The drive is a RAM disk. 
      

  3.   

    回楼上的兄弟。
    GetDriveType这个函数是不准确的,有很多移动存储设备的磁盘属性,就是和本地磁盘一样的,都是显示为DRIVE_FIXED。