Maybe you can try RegisterDeviceNotification, although it is usually not needed (Detecting Media Insertion or Removal)
WM_DEVICECHANGE never received for CD (DBT_DEVICEREMOVECOMPLETE & DBT_DEVICEARRIVAL)
Hello
My program that detects the CD removal and insertion via WM_DEVICECHANGE | DBT_DEVICEREMOVECOMPLETE and WM_DEVICECHANGE | DBT_DEVICEARRIVAL works perfectly on my desktop computer (Windows 10), but the WM_DEVICECHANGE is never received with the same program by a mini PC (Windows 10) to which is connected a laptop SATA CD reader (there is an extension SATA connector in the mini). The CD reader is recognized as such by the PC, it plays audio CD, read CD-ROM, etc... but no WM_DEVICECHANGE is triggered when a CD is ejected or inserted.
Is it a known problem? Did I miss something?
Thanks David
8 answers
Sort by: Most helpful
-
-
David L 161 Reputation points
2021-02-20T17:59:57.333+00:00 I'm going to try that, thanks again @Castorix31 , always there to help!
-
David L 161 Reputation points
2021-02-20T18:34:57.68+00:00 I tried
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; ZeroMemory(&NotificationFilter, sizeof(NotificationFilter)); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_CDROM; HDEVNOTIFY hDeviceNotify = RegisterDeviceNotification(hWnd,&NotificationFilter,DEVICE_NOTIFY_WINDOW_HANDLE); if (NULL == hDeviceNotify) { err_AddErreur(L"RegisterDeviceNotification"); return FALSE; }
with "DEFINE_GUID(GUID_DEVINTERFACE_CDROM, 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);". I found it in ntddstor.h.
But it doesn't change a thing, my breakpoint just after "WM_DEVICECHANGE:" is never reached when I eject or insert a CD.
-
David L 161 Reputation points
2021-02-20T19:36:04.35+00:00 The interface is in French, but I guess you see that it is the disc section of the computer manager.
-
David L 161 Reputation points
2021-02-20T19:51:44.143+00:00 While testing, I just saw that if I eject the CD, the WM_DEVICECHANGE is not triggered, but after that, if I try to play the CD then the WM_DEVICECHANGE breakpoint is reached. If the CD is playing while the CD is ejected, the notification is triggered too.
So the problem is when the CD is on idle. And so it never sends the notification if a CD is inserted.