Hola:
Gracias por los enlaces. Ahora puedo abrir y cerrar la bandeja.
Código Delphi:
Código:
unit Lector_bandeja;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, MMSystem;
// No olvidar añadir en uses MMSystem arriba.
type
TForm1 = class(TForm)
RadioGroup_Bandeja: TRadioGroup;
Button_Abrir: TButton;
Button_Cerrar: TButton;
Label_Mensaje: TLabel;
procedure Button_AbrirClick(Sender: TObject);
procedure Button_CerrarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure OpenCd(AOpen:Boolean);
const
DoPlay : array[Boolean] of string = ('Set cdaudio door closed wait',
'Set cdaudio door open wait');
var
MyError : LongInt;
MyErrorString : array[0..MAXERRORLENGTH - 1] of char;
begin
MyError := mciSendString(pChar(DoPlay[AOpen]), nil, 0, 0);
if MyError <> 0 then
begin
MciGetErrorString(MyError,MyErrorString,MAXERRORLENGTH - 1);
Showmessage(MyErrorString);
Exit;
end;
end;
procedure TForm1.Button_AbrirClick(Sender: TObject);
begin
OpenCd(TRUE);
Label_Mensaje.Caption := 'Abierto.';
end;
procedure TForm1.Button_CerrarClick(Sender: TObject);
begin
OpenCd(FALSE);
Label_Mensaje.Caption := 'Cerrado.';
end;
end.
Quiero seguir con detales que me falta. Lo que hace el código de arriba. Si pulso abrir, cuando la bandeja está abierta del todo, dice un mensaje "Abierto.". Mi idea es tal como hice en C#, que desde que pulse el botón Abrir, muestre en el mensaje "Abriendo...", cuando se abra del todo, diga el mensaje "Abierto.".
Esa es la cuestión.
¿Se puede hacer?
Saludos.