C# display the Device ID of CD ROM

using System; 
using System.Management;
using System.Windows.Forms; 
namespace SystemInfo
{ 
public class CDROM 
{ 
public static void Main()
{ 
try
{ 
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_CDROMDrive"); 
foreach (ManagementObject queryObj in searcher.Get())
{ Console.WriteLine("-----------------------------------"); 
Console.WriteLine("Win32_CDROMDrive instance"); 
Console.WriteLine("-----------------------------------"); 
Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
} 
} 
catch (ManagementException e)
{ 
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message); 
}
}
} 
}

Note: if you want to know other property of CD ROM like caption,CreationClassName,Drive,Manufacturer,Name,VolumeSerialNumber. Simply change the queryObj["Name"] like this