CD - saber se o usuario inseriu ou tirou o cd |
Top Previous Next |
Question/Problem/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
keep up coding!
===================== OTHER EXEMPLE -==========================
{we capture the WM_DEVICECHANGE message}
{Put this line into private section of your form's declaration} procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
{the implementation part:} procedure TForm1.WMDeviceChange (var Msg: TMessage); const CD_IN = $8000; CD_OUT = $8004; var Msg : String; begin inherited; case Msg.wParam of CD_IN : Msg := 'CD in'; CD_OUT : Msg := 'CD out'; end; ShowMessage(Msg); end;
|