WMI C# How to check programatically that CD was inserted

  • Thread starter Thread starter Maciej Brzeziñski
  • Start date Start date
M

Maciej Brzeziñski

I'm writing a simple CD-player and i would like my aplication to be
aware that cd was removed or inserted. I've managed to do sth similar
using WMI but it's not satifactory. I'm using ManagementObjectWatcher
witch a query for logical disks of type cdrom but it keeps scaning all
posible drives (also floppy drives) and i don't want that side effect.
 
Scan once and store the CD drive letter in your config file or the
environment.

Willy.
 
I have all names of the drives stored, but i want to know if cd was
removed or inserted into cdrom drive.
 
Ok, if you are running this on W2K, use Win32_CDromDrive as target and
select event notification when media is loaded.
Your WQLquery should look like this...
select * from __InstanceModificationEvent within 10 where TargetInstance ISA
'Win32_CDromDrive' and TargetInstance.MediaLoaded = true

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top