Trying to determine printer status always returns 0 for offline & online printers

a 夏天 提交于 2019-12-05 13:00:26

This Offline state (yes, there is more than one) is not actually stored as a status bit but as the PRINTER_ATTRIBUTE_WORK_OFFLINE bit in pPrnInfo2->Attributes. See this KB article.

It's set by the USB port monitor (USBMON) for a USB printer, but can also be toggled on or off by a user in the "See what's printing" window via the "Use Printer Offline" menu option:

FYI, here is the status string this attribute shows in various places in Windows 10:

  • In Print Management (and also your Print window) - "Offline"
  • Devices and Printers details view with status - "" (empty string)
  • "See what's printing" window from Devices and Printers - "Use Printer Offline"

The other offline state flags locations are:

  • PRINTER_STATUS_OFFLINE - What you were expecting in the printer info status
  • JOB_STATUS_OFFLINE - In a job status (usually the currently printing job)

Note the exact status behaviour for each printer is driver-dependent because the driver can set whatever status it likes. For instance I don't recall seeing a network printer use PRINTER_ATTRIBUTE_WORK_OFFLINE, but I recently saw an Epson receipt printer use PRINTER_STATUS_NOT_AVAILABLE.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!