0

I'm trying to detect a CD-ROM drive in an app, I'm using

ComboBox cb = new ComboBox();
        var drives = DriveInfo.GetDrives();
        foreach (var drive in drives)
        {
            if (drive.DriveType == DriveType.CDRom)
            {
                cboDrives.Items.Add(drive);
            }
        }

It picks up D:\ and E:\

D:\ is the real CD-ROM on my work PC, E:\ is a virtual drive through Alcohol 120%

I'm creating an app to read optical media to an ISO then I'm mounting that ISO in Alcohol to test if the ISO is Okay.

I want to make it easy for the users, when creating an ISO they have only one drive to choose and same for the testing of the ISO.

I could try and filter out the drive letter D:\ when the part of my app that tests ISO's is run but not all PC's have D:\ as their CD drive, my Win8.1 box for example has it as J:... and with two virtual CD drives (Alcohol and Virtual clone drive) G:\ and N:.

Is there a way to pick up the real CD drive letter by itself and then same for the virtual ones?

Update Interestingly, I've found that by testing if the drive Is Ready then only the CD drive gets picked up since it contains media whereas the virtual drive does not. Once media is mounted then it gets picked up, I think I can do something with this and/or with the duplicate question answer.

ComboBox cb = new ComboBox();
        var drives = DriveInfo.GetDrives();
        foreach (var drive in drives)
        {
            if (drive.IsReady == true)
            {
                if (drive.DriveType == DriveType.CDRom)
                {
                    cboDrives.Items.Add(drive);
                }
            }
        }
Exception
  • 71
  • 1
  • 9
  • See [duplicate](http://stackoverflow.com/questions/8525636/how-to-identify-if-a-drive-is-virtual-or-physical), you can't easily. If it were easy, piracy (especially before the phone-home games) wouldn't have florished like it did. – CodeCaster Feb 25 '15 at 11:42
  • http://stackoverflow.com/questions/8525636/how-to-identify-if-a-drive-is-virtual-or-physical - I would suggest looking at this answer. – Ryan McDonough Feb 25 '15 at 11:42
  • An interesting way to do it would be attempt to read from both, I would expect Virtual CD drives will have a quicker read speed as they are mounted virtually, a real drive would have a slower read speed? It's just a quick thought with not much research - but it might help. – Ryan McDonough Feb 25 '15 at 11:44
  • Cheers, I'll have a look at that other post, I've updated my post as well, I found something out by checking if the drive is ready. – Exception Feb 25 '15 at 22:43

0 Answers0