Hi all. I have been buggering around trying to get a CD-R tray to
Open/Close. It is no worries to do this with the standard CD drive which is
D: but E: which is the CD-R doesnt.
If anyone has any clues on this can they make a suggestion.
The code below should work on other removable drives.
Tks,
Alistair+
function TCDEvents.OpenCD(Drive: Char): Boolean;
var
Res: MciError;
OpenParm: TMCI_Open_Parms;
Flags: DWord;
S: string;
DeviceID: Word;
begin
Result := false;
S := Drive + ':';
Flags := mci_Open_Type or mci_Open_Element;
with OpenParm do begin
dwCallback := 0;
lpstrDeviceType := 'CDAudio';
lpstrElementName := PChar(S);
end;
Res := mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
if Res <> 0 then exit;
DeviceID := OpenParm.wDeviceID;
try
Res := mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0);
if Res = 0 then Result := True //The swine still returns true here
else Result:=false;
finally
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
end;
end;
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz