如何取得电脑的最后一个盘符号,即光驱盘符号?再线等待

fansnaf 2003-02-13 04:18:41
rt
...全文
82 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
slley 2003-02-13
  • 打赏
  • 举报
回复
谁说电脑一定有光驱?
谁说电脑的最后一个盘一定是光盘?
谁说电脑只能有一个光驱动?
Eastunfail 2003-02-13
  • 打赏
  • 举报
回复
function CDROM:string;
var curDrive:char;
begin
for curDrive='Z' downto 'D'
if GetDriveType(PChar(curDrive+':\'))=DRIVE_CDROM then
begin
Result:=curDrive+':\';
exit;
end;
raise exception.create('No cdrom detected.');
end;
ehom 2003-02-13
  • 打赏
  • 举报
回复
for t := 0 to 25 do
begin
DriveRoot := Chr(t + Ord('a')) + ':\';
if GetDriveType(PChar(DriveRoot)) = DRIVE_CDROM then
//...
end;

因为A:、B:肯定不是光驱,只判断光驱可从C:开始,2-25~~~
ptma 2003-02-13
  • 打赏
  • 举报
回复
补充:设置DriveComboBox1不可见
ptma 2003-02-13
  • 打赏
  • 举报
回复
DriveComboBox1.Items.Strings[DriveComboBox1.Items.Count-1]
如果有映射的网络驱动器就不行了
ehom 2003-02-13
  • 打赏
  • 举报
回复
最后一个不一定就是光驱,计算机上不一定有光驱,也不一定就只有一个光驱~~~

从'A'-'Z'遍历一遍~~~

用API GetDriveType判断驱动器类型

返回值含义:

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.
hk75 2003-02-13
  • 打赏
  • 举报
回复
1 使用PSAPI
2 应用 WMI

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧