unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;type
  TForm1 = class(TForm)
    Label1: TLabel;
  private
    procedure wmdevicechange(var msg:tmessage);
    message WM_DEVICECHANGE;    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.DFM}
procedure tform1.wmdevicechange(var msg:tmessage);
const
DBT_DEVICEARRIVAL=$8000;
DBT_DEVICEMOVECOMPLETE=$8004;
var
  tempstr:string;
begin
  inherited;
  case msg.WParam of
  DBT_DEVICEARRIVAL      :tempstr:='你插入了CD';
  DBT_DEVICEMOVECOMPLETE :tempstr:='你弹出了CD';
  end;
  showmessage(tempstr);end;end. 
看一下这个例子吧!
捕获光区消息的例子!