PrinterSettings
具有PaperSources
属性,该属性是打印机可用的纸张来源(纸盘)的集合。
但是,我需要使用WMI
获取纸张来源,但我看到的只是诸如“ PaperSizesSupported”和“ PaperTypesAvailable”之类的属性。
WMI中的纸张来源属性在哪里?
答案 0 :(得分:0)
不幸的是,没有包含提供所需信息的WMI类。在.NET的PrinterSettings
类中,此信息是通过对DeviceCapabilities()
中的winspool.drv
函数的pinvoke调用收集的。他们没有在任何ROOT\cimv2
WMI类中提供这些功能,包括以下各项:
还有其他一些打印机类,但是这些打印机类包括用于查询的任何数据。如果您正在.NET中开发解决方案,建议您仅使用System.Drawing命名空间(there is an answer here with a great example)中的PrinterSettings类。如果您使用脚本语言,则可以通过在PowerShell中使用.NET程序集来完成类似的工作:
Add-Type -AssemblyName System.Drawing
$PrinterSettings = New-Object System.Drawing.Printing.PrinterSettings
ForEach ($Printer in Get-Printer) {
$PrinterSettings.PrinterName = $Printer.Name
Write-Host $Printer.Name
Write-Host $PrinterSettings.PaperSources
}