这是一个很棘手的问题。
一般是通过磁盘的属性来判断的,但是这个是不准的,有很多移动存储设备的磁盘属性,就是和本地磁盘一样的。
后来又想到通过盘符的顺序,认为光驱盘符之后的磁盘就是移动存储设备,这也是不准的,很多时候,移动存储设备插入后,盘符会在光驱盘符之前出现。到底怎样才能准确无误的来判断呢?
一般是通过磁盘的属性来判断的,但是这个是不准的,有很多移动存储设备的磁盘属性,就是和本地磁盘一样的。
后来又想到通过盘符的顺序,认为光驱盘符之后的磁盘就是移动存储设备,这也是不准的,很多时候,移动存储设备插入后,盘符会在光驱盘符之前出现。到底怎样才能准确无误的来判断呢?
解决方案 »
- MFC 双屏显示
- 请教各位高手关于Edit控件问题,急!先谢谢了
- 如何使用MFC改变WINDOWS的背景和主题
- 我在MFC工程中用WINCAP库为什么老是出现连接错误呢?而在WIN32 console工程下面却可以通过,这是怎么回事?
- 如何让激活其他程序中变灰的菜单项?
- 用过windows API函数WNetGetConnection(lplocal,lpremote,lplengh);请进
- 如何用程序來完成對windows系統下設備的管理
- 自制浏览器时,网页弹出一个msg对话框后为什么不能自动刷新?
- 请教!如何将数据库中的 OLE对象 读出 并写入文件?
- 老问题,我找过都没有好好回答,现在重提,望大家捧场:大家用VC做什么?
- 如何做到将一个很小的配置文件写入到移动存储设备中,但却不被使用者看到。
- 上下文菜单的菜单资源无法通过可视化添加吗?就想窗口菜单一样?
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;
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.
GetDriveType这个函数是不准确的,有很多移动存储设备的磁盘属性,就是和本地磁盘一样的,都是显示为DRIVE_FIXED。