如何检测CD-ROM的状态(100分)

  • 主题发起人 主题发起人 lig
  • 开始时间 开始时间
L

lig

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位大虾:
如何判断CD-ROM的仓门当前状态是开着的还是关着的。
E-MAIL to ligwin@cmmail.com
 
这个问题以前讨论过,查一查以答问题吧
 
下面这个函数可以显示是否就绪。(From Borland)
function DiskInDrive(Drive: Char): Boolean;
var ErrorMode: word;
begin
{ make it upper case }
if Drive in ['a'..'z'] then
Dec(Drive, $20);
{ make sure it's a letter }
if not (Drive in ['A'..'Z']) then
raise EConvertError.Create('Not a valid drive ID');
{ turn off critical errors }
ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
try
{ drive 1 = a, 2 = b, 3 = c, etc. }
if DiskSize(Ord(Drive) - $40) = -1 then
Result := False
else
Result := True;
finally
{ restore old error mode }
SetErrorMode(ErrorMode);
end;
end;
 
再添点:
打开CDROM: mciSendString('Set cdaudiodo
or open wait', nil, 0, handle);
关闭CDROM:
mciSendString('Set cdaudiodo
or closed wait', nil, 0, handle);
 
This shoulddo
the trick..
function IsCDROM(DriveNum: Integer): Boolean;
assembler;
asm
MOV AX,1500h { look for MSCDEX }
XOR BX,BX
INT 2fh
OR BX,BX
JZ @Finish
MOV AX,150Bh { check for using CD driver }
MOV CX,DriveNum
INT 2fh
OR AX,AX
@Finish:
end;
BTW under Win32 GetDriveType properly returns a CD-ROM drive.
A:
Function IsCdRom(DriveNum : Word) : Boolean;
Var
F : WordBool;
begin
asm
mov ax, 1500h { test for presence of MSCDEX }
xor bx, bx
int 2fh
mov ax, bx { if bx = zero, MSCDEX is not present }
or ax, ax { return FALSE }
jz @no_mscdex
mov ax, 150bh { MSCDEX drive check }
mov cx, DriveNum { cx contains drive }
int 2fh
@no_mscdex:
mov f,ax
end;
Result := F;
{ Assign function return value }
end;
 
to pwpengwei
按照你的提示我查了一下,但是结果不太理想.
to jams
>>是什么意思啊!
to lha
好像有些跑题啊!
to walala
我没有试,但是看上去好像可行。
to 郑宇轩
现在的BCB&DELPHI中好像无法直接调用中断啊!
 
后退
顶部