Here's how to be notified when CD drawer is opened or closed:
~~~~~~~~~~~~~~~~~~~~~~~~~
{Put this line into private section
of your form's declaration}
procedure WMDeviceChange(var Msg: TMessage) ;
message WM_DEVICECHANGE;
{the implementation part:}
procedure TForm1.WMDeviceChange
(var Msg: TMessage) ;
const
CD_IN = $8000;
CD_OUT = $8004;
var
Msg : String;
begin
inherited;
case Msg.wParam of
CD_IN : Msg := 'CD in';
CD_OUT : Msg := 'CD out';
end;
ShowMessage(Msg) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~