WMI to detect printer online/offline

  • Thread starter Thread starter Andy Foster
  • Start date Start date
A

Andy Foster

Hi,

Sorry for this long preamble, but it will help with my question....

I'm developing a dedicated XP Embedded application.

If the user prints fom the application, but no printer is available, a
typical "printer offline" dialog will appear (Printer dependent, in my case
a Canon i550). This is undesirable, the customer wants it just to ignore the
print request, and no dialog ever be visible.

For this reason, I want to detect if the printer is Online/offline BEFORE
attempting to print. If offline, I can then abort the print, and won't see
the dialog.

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
dcoument is sent, whichis too late, because I will then see the dialog.

It seems that I could use WMI. I've tried using
GetObject(sPrinter).InstancesOf("win32_Printer")

and then looking at Printer.PrinterStatus, but the same effect is seen as
with Win32 API.



So, the question is, how can I tell if a printer is offline/online without
sending a print to it?

I think I have to use WMI extensions to the printer WDM driver?

Any pointers, advice recieved with thanks!

Andy Foster
 
Back
Top