http://flyxxtt.blogbus.com/logs/43181576.html

函数原型:
UINT GetDriveType(LPCTSTR lpRootPathName)

参数lpRootPathName是根目录,如"C:\",一定要加上反斜杠。
如果给此参数传入NULL将返回程序当前目录的驱动器类型返回值所代表的类型

请看下面的例子。

使用例子:

wstring getDriveType( LPCTSTR lpRootPathName )
{
  wstring typename;
  unsigned int type = GetDriveType( _T( "C:\\" ) );       //得到C盘类型
  switch ( type )
  {
    case DRIVE_UNKNOWN:
      typename = _T( "未知类型" );
      break;
    case DRIVE_NO_ROOT_DIR:
      typename = _T( "无效的根路径" );
      break;
    case DRIVE_REMOVABLE:
      typename = _T( "可移动磁盘或软盘" );
      break;
    case DRIVE_FIXED:
      typename = _T( "本地硬盘" );
      break;
    case DRIVE_REMOTE:
      typename = _T( "网络磁盘" );
      break;
    case DRIVE_CDROM:
      typename = _T( "CD-ROM" );
      break;
    case DRIVE_RAMDISK:
      typename = _T( "RAM" );
      break;
    default:
      typename = _T( "未知类型" );
  }
  return typename;
}

 

相关文章:

  • 2022-12-23
  • 2021-09-04
  • 2021-11-30
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-13
  • 2021-08-07
  • 2021-09-24
  • 2021-11-12
  • 2021-10-23
相关资源
相似解决方案