This came up from my other question about IMAPI2 is it possible to identify if a DVD/CD drive is virtual and not physical?
In some circumstances, you may need to give your virtual machine direct access to a physical hard drive on your host computer — using the disk type referred to as a physical disk. A virtual disk is a file or set of files that appears as a physical disk drive to a guest operating system.
Open the System Information file. In the System Information window, click the + symbol next to Components. Click the + next to Storage and click Drives. In the right-side of the window, you see information about the hard drive including its capacity and serial number.
Virtual hard drives are essentially a computer within a computer, but with storage rather than processing power. They are typically attached to virtual machines and function as their data drives. Virtual hard drives have similar functionalities as physical external hard drives and rely on your computer's memory.
The purpose of a virtual drive is to act exactly as its physical counterpart, just without the physical media. Both kinds of drives work with the operating system in the same manner as a device driver. I highly doubt the difference between them would be visible within the Win32 API. That would be counter-intuitive to the virtual drive's purpose.
I looked at the information provided by WMI (which is accessible in C#) and found something of interest. The device id of my virtual drive began with ‘SCSI’ whereas the device id of my physical SATA drive began with ‘IDE’. I believe most of (all of?) virtual drive software emulates a SCSI drive; I'm not sure. Typically, a user would have either an IDE or SATA optical drive which would both have an id beginning with ‘IDE’.
Virtual Drive Device: "SCSI\CDROM&VEN_ELBY&PROD_CLONEDRIVE&REV_1.4\1&00000000&0&000000"
Real Drive Device: "IDE\CDROMASUS_DRW-24B1ST_________________________1.03____\5&295AF142&0&5.0.0"
Notice in my example device ids that the virtual drive is clearly identified as the Clone Drive software. You could check the manufacturer and product name against a known list of virtual drive software. This might yield a lot of false negatives and be very hard to maintain.
Either way, I am not confident that searching for features in the device id would be a highly reliable solution. There might be virtual drives which identify themselves differently. I only tested Clone Drive and Daemon Tools in researching your question.
If you were to use this approach for copyright protection (what else would you use it for?) then you have to consider if the chance of a false virtual drive determination is worth angering your customers.
Here is the C# code for inspecting the drives using WMI and accessing the device id. You will need to reference the System.Management assembly.
string driveLetter = "F";
ManagementObjectSearcher diskQuery = new ManagementObjectSearcher(String.Format("SELECT * FROM Win32_CDROMDrive WHERE Drive='{0}:'", driveLetter));
ManagementObject diskResult = diskQuery.Get().OfType<ManagementObject>().SingleOrDefault();
string deviceID = null;
if (diskResult != null)
deviceID = (string)diskResult["DeviceID"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With