用下列MCI命令可以判断光驱状态并使其弹出关闭:
program cdinout;
uses mmSystem;
var
MCIO : TMCI_Open_Parms;
MCIS : TMCI_Status_Parms;
begin
MCIO.lpstrDeviceType := PChar(MCI_DEVTYPE_CD_AUDIO);
if mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE or MCI_OPEN_TYPE_ID or
MCI_OPEN_SHAREABLE, LongInt(@MCIO) )= 0 then
begin
MCIS.dwItem := MCI_STATUS_READY;
mciSendCommand(MCIO.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM
or MCI_WAIT, LongInt(@MCIS));
if MCIS.dwReturn<> 0 then
mciSendCommand(MCIO.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0)
else
mciSendCommand(MCIO.wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0);
mciSendCommand(MCIO.wDeviceID, MCI_CLOSE, MCI_WAIT, 0);
end;
end.