I want to detect if a printer is Online/offline BEFORE attempting to print. If it is offline - the print dialog will not be Visible.
The Win32 API's "OpenPrinter" etc. seem to work on the spooler queue, rather than the printer itself, and will only report the printer offline AFTER a document is sent, whichis too late.
QUESTION: How can I tell if a printer is offline/online without sending a print out to it?
EDIT:
Offline - printer is turned off
OnLine - printer is turned On
Your printer's built-in menu should show which network it's connected to, or check your printer's manual for more info. Verify that your printer is not in Use Printer Offline mode. Select Start > Settings > Devices > Printers & scanners. Then select your printer > Open queue.
Turn on the printer and try printing a page. If this doesn't work, shut down the computer, and then try using a different port on the computer. If this still doesn't work, reverse the cable and try one more time to eliminate a faulty cable or connection as the problem.
Right-click on your printer to see a list of options. To view the print queue, select "See what's printing." To check general printer status, select "Properties," and to figure out if something is wrong with the printer select "Troubleshoot."
Presumably you know the name of the printer or other details about it.
Well, then simply use EnumPrinters
with PRINTER_INFO_2
and check for PRINTER_STATUS_OFFLINE
(or any other status that you want avoid).
Alternately you could try to use the SetupDi*
functions (aka Setup API) to figure out whether the USB device matching the printer is connected at this very moment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With