PC Review Forums Newsgroups Windows XP Windows XP WMI WMI to detect printer online/offline

Reply

WMI to detect printer online/offline

 
Thread Tools Rate Thread
Old 20-08-2004, 10:09 PM   #1
Andy Foster
Guest
 
Posts: n/a
Default WMI to detect printer online/offline


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



  Reply With Quote
Old 23-08-2004, 06:18 PM   #2
Alan Morris\(MSFT\)
Guest
 
Posts: n/a
Default Re: WMI to detect printer online/offline

You would need to force a port status update to set the printer status.
This is assuming that the Port is a Standard TC/IP Port with SNMP enabled.

--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto

This posting is provided "AS IS" with no warranties, and confers no rights.

"Andy Foster" <nospam@nospam.com> wrote in message
news:uoAQaJwhEHA.4092@TK2MSFTNGP10.phx.gbl...
> 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
>
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off