This snippet shows you how to get information about all CD / DVD drives on your machine using WMI and C#. To run the code you need to add reference to System.Management.

ManagementObjectSearcher mgmtObjects = 
  new ManagementObjectSearcher("Select * from Win32_CDROMDrive");

foreach (var item in mgmtObjects.Get())
{
  Console.WriteLine("Drive Letter - \t" + item["Drive"]);
  Console.WriteLine("Name - \t" + item["Name"]);
}

 

This code snippet will print out the letter and the name of all CD or DVD drives on a machine. Here is the output on my PC.

image

Tagged with:
 

One Response to Get CD Or DVD Drive Information Using WMI And C#

  1. I have been using my PC for4 months and I have found that windows does indeed suck.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>