b]控制CD-ROM的弹出和关闭/判断是否有盘[/b]
在uses中添加mmsystem。
procedure TsystemForm.Button28Click(Sender: TObject);
begin
mcisendstring('set cdaudio do
or
open',nil,0,handle);//Open
end;
procedure TsystemForm.Button29Click(Sender: TObject);
begin
mcisendstring('set cdaudio do
or
closed',nil,0,handle);//Close
end;
包括判断是否有盘
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.