现在不是有那种移动存储盘(优盘)嘛,在DELPHI中怎样检测是否有移动存储盘存在,且盘符是什么?(50分)

  • 主题发起人 主题发起人 del520
  • 开始时间 开始时间
D

del520

Unregistered / Unconfirmed
GUEST, unregistred user!
要检测一个移动存储盘是否存在,且知道盘符是什么,该怎么办?
 
检测交给系统来做,你只管从系统读取相关信息不就行了,只是想想,没做过
 
还不是和普通硬盘一样操作。
 
和硬盘可有不同啊,这个可是和软盘相似的,比如说我做一个备份模块就有三个选项
1.软盘
2.优盘
3.硬盘
如果我选择软盘和优盘都不需要指明路径,直接存到根目录下就够了。
但如果是硬盘的话按常规是要指定存储路径了。

我怎么知道这个优盘是否存在,盘符是多少?
 
从A-Z检测磁盘类型

The GetDriveType function determines whether a disk drive is a removable,
fixed, CD-ROM, RAM disk, or network drive.

UINT GetDriveType(
LPCTSTR lpRootPathName // address of root path
);


Parameters

lpRootPathName

Points to a null-terminated string that specifies the root directory of the
disk to return information about. If lpRootPathName 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
0 The drive type cannot be determined.
1 The root directory does not exist.
DRIVE_REMOVABLE The drive 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.
 
如果操作系統不支持的話﹗你也不可能檢測到﹗如果操作支持的話﹐就讓系統自己去做吧﹗
 
接受答案了.
 
原来是这个意思。
 
后退
顶部