Home / Code Snippets / Blog article: Get CD Or DVD Drive Information Using WMI And C#

| RSS

Get CD Or DVD Drive Information Using WMI And C#

March 9th, 2009 | 1 Comment | Posted in Code Snippets

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

Leave a Reply 5350 views, 3 so far today |
Tags: , ,
Follow Discussion

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

  1. Jeanie Rackham Says:

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

Leave a Reply