如何以编程方式确定 Win32 中光驱的功能

发布于 2024-07-05 01:05:46 字数 424 浏览 6 评论 0原文

我正在尝试创建一个部署工具,该工具将根据系统上找到的硬件安装软件。 我希望该工具能够确定光驱是否是写入器(以确定是否应安装刻录软件)或可以读取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情话难免假 2024-07-12 01:05:46

您可以使用 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 the Win32_PhysicalMedia information for the physical media the drive uses; the MediaType property to get what media it uses (CD, CDRW, DVD, DVDRW, etc, etc).

蓝天 2024-07-12 01:05:46

平台 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文