如何在没有插入磁盘介质的情况下以编程方式区分CD驱动器和DVD驱动器?

如何在没有插入磁盘介质的情况下以编程方式区分CD驱动器和DVD驱动器?

问题描述:

亲爱的朋友们:

我搜索了互联网,无法找到一种方法以编程方式知道磁盘驱动器是支持DVD还是只有CD,而无需将磁盘介质插入驱动器。我之前尝试过WMI失败了。 Windows操作系统可以正确显示cdrom或dvd驱动器信息。欢迎使用C ++,C#或VB解决方案!提前致谢!



修改

还有一件事:

我测试过两台机器上的注册表:一台带有DVD + -RW,另一台带有CD-RW。两台机器在注册表中都有DefaultDvdRegion = 1,尽管一台机器只有CD-RW。

ManagementObject的Name和DeviceID确实反映了驱动器的类型:

Dear friends:
I searched the internet and could not find a way to programmatically know whether a disk drive supports DVD or only CD without the need to insert a disk media into the drive. I have tried WMI unsuccessfully before. Windows operating system can display cdrom or dvd drive information correctly. C++, C# or VB solutions are all welcome! Thanks in advance!

Modification
One more thing:
I tested the registry on two machines: one with a DVD+-RW and another with a CD-RW. Both of the machines have DefaultDvdRegion = 1 in the registry although one machine has only CD-RW.
The Name and DeviceID of the ManagementObject do reflect the type of the drive:

DVD+-RW has this: "IDE\\CDROMTSSTCORP_DVD+-RW_TS-H653B_______________D200____\\5&1A4D1015&0&0.0.0"

CD-RW has this  : "IDE\\CDROMTSSTCORP_CD-RW___TS-H292B_______________DE03____\\5&70107E7&0&0.0.0"





结束修改

你试过这个:



http://msdn.microsoft.com/en-us/library /system.environment.getlogicaldrives.aspx [ ^ ]


从Randor(David Delaune)看一下这个: b $ b

http://www.codeproject.com/Messages/2886882/Re-How-to-determine-programatically-if-a-drive-let.aspx [ ^ ]
Have a look at this from Randor (David Delaune):

http://www.codeproject.com/Messages/2886882/Re-How-to-determine-programatically-if-a-drive-let.aspx[^]


在C,C ++中不确定。但是在C#中,我们可以使用System.IO包/名称空间的DriveInfo类轻松获取此信息。它具有各种有用的属性,其中DriveType指示驱动器是否是以下任何一个:CDRom,Fixed,Unknown,Network,NoRootDirectory,Ram,Removable或Unknown。值列在DriveType枚举中。
Not sure in C, C++. But in C#, we can easily fetch this info using DriveInfo class of System.IO package/namespace. It has various useful property, out of which DriveType indicates whether a drive is any of: CDRom, Fixed, Unknown, Network, NoRootDirectory, Ram, Removable, or Unknown. Values are listed in the DriveType enumeration.