如何识别一个驱动器是虚拟或物理 [英] How to identify if a drive is virtual or physical

查看:112
本文介绍了如何识别一个驱动器是虚拟或物理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这从我的约IMAPI2等问题提出了是否有可能以确定是否有DVD / CD驱动器是虚拟的,而不是物理?

This came up from my other question about IMAPI2 is it possible to identify if a DVD/CD drive is virtual and not physical?

推荐答案

的虚拟驱动器的目的是要精确地充当其物理对应物,只是没有物理介质。这两种驱动器与操作系统中相同的方式作为设备驱动程序运行。我很怀疑他们之间的差异将在Win32 API中可见。这将是反直觉的虚拟驱动器的目的。

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.

我看着通过WMI(这是在C#中访问)提供的资料,发现一些有趣的东西。我的虚拟驱动器的设备ID开始'SCSI',而我的身体SATA驱动器的设备ID开始与IDE。我相信大多数(所有?)的虚拟光驱软件模拟SCSI驱动器的;我不确定。通常情况下,用户将有两种IDE或SATA光驱这会都与IDE开头的ID。

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"

在我的例子设备ID请注意,虚拟驱动器被明确确定为克隆驱动器软件。你可以针对虚拟光驱软件的已知列表检查制造商和产品名称。这可能会产生大量的漏报,并很难维护。

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.

无论哪种方式,我没有信心,在设备ID搜索功能将是一个高度可靠的解。有可能是其自己的身份不同的虚拟驱动器。我只测试了克隆驱动器和守护工具在研究你的问题。

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.

下面是检查使用WMI驱动器和访问设备ID的C#代码。你将需要引用System.Management组件

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"];

这篇关于如何识别一个驱动器是虚拟或物理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆