Author: Jonas Bilinkevicius
Need to know when the user inserts/extracts a CD?
Answer:
there's a message you can intercept to know this: WM_DEVICECHANGE
so... the rest is easy on the private section of your form, declare the function:
Private
1 { Private declarations }2 3 procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
4 5 //the implement it: 6 7 procedure TForm1.WMDeviceChange(var Msg: TMessage);
8 const9 CD_IN = $8000;
10 CD_OUT = $8004;
11 begin12 inherited;
13 case Msg.wParam of14 CD_IN: ShowMessage('CD in'); //or do whatever you want!!15 CD_OUT: ShowMessage('CD out')
16 end17 end;
that's it... you'll receive a message when you put a CD in/out... try it then just instead of showing 'CD in'/'CD out'... do whatever you want