如何以编程方式确定 Win32 中光驱的功能
我正在尝试创建一个部署工具,该工具将根据系统上找到的硬件安装软件。 我希望该工具能够确定光驱是否是写入器(以确定是否应安装刻录软件)或可以读取 DVD(以确定是否应安装播放器)。 我尝试使用以下代码,
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objItem in colItems
Wscript.Echo "MediaType: " & objItem.MediaType
Next
但它总是以 CD-ROM 响应
I'm trying to create a deployment tool that will install software based on the hardware found on a system. I'd like the tool to be able to determine if the optical drive is a writer (to determine if burning software sould be installed) or can read DVDs (to determine if a player should be installed). I tried uing the following code
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objItem in colItems
Wscript.Echo "MediaType: " & objItem.MediaType
Next
but it always respons with CD-ROM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 WMI 枚举 Windows 对驱动器的了解; 获取
Win32_DiskDrive
您应该能够从中获取 < 的实例code>Win32_PhysicalMedia 驱动器使用的物理介质的信息; MediaType 属性以获取其使用的媒体(CD、CDRW、DVD、DVDRW 等)。You can use WMI to enumerate what Windows knows about a drive; get the
Win32_DiskDrive
instance from which you should be able to grab the theWin32_PhysicalMedia
information for the physical media the drive uses; the MediaType property to get what media it uses (CD, CDRW, DVD, DVDRW, etc, etc).平台 SDK - IDiscMaster::EnumDiscRecorders (XP / 2003)
DirectX 和 DirectShow 具有广泛的接口,可与 DVD 一起使用
Else 枚举磁盘驱动器并尝试触发支持提取类型信息的 DeviceIonControlCode。
祝你好运
Platform SDK - IDiscMaster::EnumDiscRecorders (XP / 2003)
DirectX and DirectShow has extensive interfaces to work with DVD
Else enumerate disk drives and try firing a DeviceIonControlCode that supports extarcting the type info.
Good luck