CD Change Notifications

Environment: The demo was written using Visual C++ 6.0

Getting Notification of CD-ROM Insertion or Removal:

Some Win32 applications need to know when the user inserts or removes a compact disc from a CD-ROM drive without polling for media changes. Windows NT provide a way to notify these applications through the WM_DEVICECHANGE message. This article explains how to handle the WM_DEVICECHANGE message to detect CD-ROM media changes. Furthermore is describes a way to cancel Autoplay application using the QueryCancelAutoPlay event.

Download demo project - 18 KB

Date Last Updated: April 4, 1999



Comments

  • From an ActiveX control?

    Posted by Legacy on 07/08/2003 12:00am

    Originally posted by: Mike

    How can I get the WM_DEVICECHANGE message from within an ActiveX control?

    Reply
  • To make this work in MFC is quite simple

    Posted by Legacy on 08/20/2001 12:00am

    Originally posted by: Uday A. Prabhune

    I made MFC dialog application named CDChange.
    
    The application class is CCDChangeApp.
    The dialog class is CCDChangeDlg.
    The application should stop CD autoplay as long as the application is running. For this to work following things need to be done:

    1. In the CDChangeDlg.cpp file, add-
    const UINT WM_AUTOPLAY = ::RegisterWindowMessage(_T("QueryCancelAutoPlay"));
    2. In the message map in CDChangeDlg.cpp add this
    BEGIN_MESSAGE_MAP(CCDChangeDlg, CDialog)
    //{{AFX_MSG_MAP(CCDChangeDlg)
    ...
    //}}AFX_MSG_MAP
    ON_REGISTERED_MESSAGE(WM_AUTOPLAY, OnAutoPlay)
    END_MESSAGE_MAP()
    3. In the CDChangeDlg.cpp, add the OnAutoPlay function.
    BOOL CCDChangeDlg::OnAutoPlay()
    {
    return TRUE; // Cancel autoplay
    }
    4. In the CDChangeDlg.h file, add OnAutoPlay function declaration.
    class CCDChangeDlg : public CDialog
    {
    ...
    BOOL OnAutoPlay();
    }

    That is it. When a CD is inserted, OnAutoPlay function is called which cancels the CD autoplay.

    Reply
  • how to get second cd rom notification

    Posted by Legacy on 09/19/2000 12:00am

    Originally posted by: craig

    It seems the sample works only for the first cd-rom drive. what if i have a second cd-rom attached on the system and i need to get notification about it? any suggestion is appreciated.

    Thanks.

    --Craig

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • With 81% of employees using their phones at work, companies have stopped asking: "Is corporate data leaking from personal devices?" and started asking: "How do we effectively prevent corporate data from leaking from personal devices?" The answer has not been simple. ZixOne raises the bar on BYOD security by not allowing email data to reside on the device. In addition, Zix allows employees to maintain complete control of their personal device, therefore satisfying privacy demands of valued employees and the …

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds