1. Home
  2. Computing & Technology
  3. Delphi Programming

Be notified: CD in/out

By , About.com Guide

Here's how to be notified when CD drawer is opened or closed:

~~~~~~~~~~~~~~~~~~~~~~~~~
{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;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Capture the output from a command/console (DOS) window
« Empty Recycle Bin

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2001 Delphi Tips
  7. Be notified: CD in/out

©2009 About.com, a part of The New York Times Company.

All rights reserved.