| |
| How can I close the CD Tray in code? |
 |
How can I close the CD Tray in code?
Make a call to the MMSystem function mciSendCommand
sending the MCI_SET_DOOR_CLOSED command. Example: uses MMSystem; procedure CloseCD(Drive : char);
var
mp : TMediaPlayer;
begin
result := false;
Application.ProcessMessages;
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.FileName := Drive + ':';
mp.Open;
Application.ProcessMessages;
mciSendCommand(mp.DeviceID,
MCI_SET, MCI_SET_DOOR_CLOSED, 0);
Application.ProcessMessages;
mp.Close;
Application.ProcessMessages;
mp.free;
result := true;
end; procedure TForm .Button Click(Sender: TObject);
begin
CloseCD('D');
end;
7/ 6/98 4:3 :28 PM
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|