unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  protected
    procedure WMDeviceChange(var Msg : TMessage); message WM_DEVICECHANGE;
  end;

const
  DBT_QUERYCHANGECONFIG = $0017;
  DBT_CONFIGCHANGED = $0018;
  DBT_CONFIGCHANGECANCELED = $0019;
  DBT_DEVICEARRIVAL = $8000;
  DBT_DEVICEQUERYREMOVE = $8001;
  DBT_DEVICEQUERYREMOVEFAILED = $8002;
  DBT_DEVICEREMOVEPENDING = $8003;
  DBT_DEVICEREMOVECOMPLETE = $8004;
  DBT_DEVICETYPESPECIFIC = $8005;
  DBT_USERDEFINED = $FFFF;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMDeviceChange(var Msg : TMessage);
const
  PLYTA_WLOZONA  = $8000;
  PLYTA_WYSUNIETA = $8004;
begin
  case Msg.wParam of
    PLYTA_WLOZONA: ShowMessage('Włożono płytę CD/DVD do napędu.');
    PLYTA_WYSUNIETA: ShowMessage('Płyta CD/DVD została wyjęta z napędu.');
  end;
end;


end.
