How to determine if a connected USB printer is on or off?

I want to determine if the printer is online / offline BEFORE trying to print. If it is disabled, the print dialog will not be visible.

Win32 API "OpenPrinter", etc., seems to work in the spooler queue, and than the printer itself, it will only report the printer offline AFTER a document is sent, which is too late.

Question : How do I know if a printer is offline / online without sending a printout to it?

EDIT:

Offline - printer is turned off OnLine - printer is turned On 
+7
source share
2 answers

Presumably you know the name of the printer or other information about it.

Well, then just use EnumPrinters with PRINTER_INFO_2 and check PRINTER_STATUS_OFFLINE (or any other status you want to avoid).

Alternatively, you can try using the SetupDi* functions (also known as the Setup API) to find out if a USB device matching the printer is connected at this very moment.

+4
source

I do not think that's possible.

As you already found out, this is abstracted using a spooler, and the state of the spooler does not always reflect the state of the printer.

So, this is by design in Windows.

If you have only one type of printer, you can request one if it is connected to USB.

0
source

All Articles