WMI to detect printer online/offline

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top