function TCdrom.EjectCdrom(open1:Boolean;drives:string):boolean;
var
open:MCI_OPEN_PARMS;
status:MCI_STATUS_PARMS;
flag:word;
ferror:longint;
begin
FillChar(Open, SizeOf(MCI_Open_Parms), 0);
open.lpstrDeviceType:=PCHAR(MCI_DEVTYPE_CD_AUDIO);
open.dwCallback:=0;
OPEN.lpstrElementName:=pchar(drives);
FLAG:=MCI_OPEN_TYPE OR MCI_OPEN_TYPE_ID OR MCI_OPEN_ELEMENT OR MCI_OPEN_SHAREABLE;
if MCISENDCOMMAND(0,MCI_OPEN,FLAG,Longint(@open))=0
then
begin
status.dwItem:=MCI_STATUS_READY;
if open1
then
ferror:=MCISENDCOMMAND(open.wDeviceID,MCI_SET,MCI_SET_DOOR_open,0);
else
ferror:=MCISENDCOMMAND(open.wDeviceID,MCI_SET,MCI_SET_DOOR_closed,0);
ferror:=MCISENDCOMMAND(OPEN.wDeviceID,MCI_CLOSE,MCI_WAIT,0);
end;
end;