Mega Code Archive

 
Categories / Delphi / Multimedia
 

Get notified CD inout

Title: get notified: CD in/out Question: 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: &nbsp&nbspPrivate &nbsp&nbsp&nbsp&nbsp{ Private declarations } &nbsp&nbsp&nbsp&nbspProcedure WMDeviceChange(Var Msg: TMessage); message WM_DEVICECHANGE; the implement it: Procedure TForm1.WMDeviceChange(Var Msg: TMessage); Const &nbsp&nbspCD_IN = $8000; &nbsp&nbspCD_OUT = $8004; Begin &nbsp&nbspInherited; &nbsp&nbspCase Msg.wParam Of &nbsp&nbsp&nbsp&nbspCD_IN : ShowMessage('CD in'); //or do whatever you want!! &nbsp&nbsp&nbsp&nbspCD_OUT : ShowMessage('CD out') &nbsp&nbspEnd 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 keep up coding! - The source code of the article was formatted using my: PAS 2 HTML converter EberSys