2007. június 8., péntek

Get notified: CD in/out


Problem/Question/Abstract:

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
{ Private declarations }

procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;

the implement it:

procedure TForm1.WMDeviceChange(var Msg: TMessage);
const
  CD_IN = $8000;
  CD_OUT = $8004;
begin
  inherited;
  case Msg.wParam of
    CD_IN: ShowMessage('CD in'); //or do whatever you want!!
    CD_OUT: ShowMessage('CD out')
  end
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

Nincsenek megjegyzések:

Megjegyzés küldése