To open or close the CDROM, call OpenCloseCD() passing either True (to open) or False (to close). This procedure will work on all types of CDs and will also work if there is no CDROM in the drive. This is similar to OpenCloseCDDrive() except that this one doesn't require a drive letter. Thanks to Bence Parhuzamos for this code. usesMMSystem;
procedure OpenCloseCD(TrueForOpenFalseForClose: boolean);
{ Works as well as OpenCloseCDDrive() above, }
{ but you don't have to specify a drive letter. }
{ Thanks to Bence Parhuzamos [[email protected]] for this code. } var
mci: TMCI_Open_Parms;
begin
FillChar(mci, SizeOf(mci), #0);
mci.lpstrDeviceType := PChar('CDAudio');
mciSendCommand(0, mci_Open, mci_Open_Type, Longint(@mci));
mciSendCommand(mci.wDeviceID, mci_Set, 256*(Byte(not TrueForOpenFalseForClose)+1), 0);
{ MCI_SET_DOOR_OPEN = 256 }
{ MCI_SET_DOOR_CLOSED = 512 }
mciSendCommand(mci.wDeviceID, mci_Close, 0, 0);
end;