|
|
|
date: Thu, 4 Sep 2008 13:51:15 -0700 (PDT),
group: microsoft.public.win32.programmer.wmi
back
Enumerating Local Physical Printers
Although it seems like it should be quite simple, it turns out to be
rather difficult to reliably enumerate only local physical printers on
a machine. An obvious starting point would be something like:
Select * from Win32_Printer where Local=true and Network=false
The problem here is that many drivers, such as PDF and XPS document
writers and fax drivers masquerading as printers are also turned up in
such an enumeration.
Alright, then, you say, we should at least be able to exclude fax
drivers by looking at the PRINTER_ATTRIBUTE_FAX bit of the Attributes
property? Well, sometimes, with some drivers.
Okay, then, if we're willing to limit ourselves to COM, LPT and USB
ports shouldn't we be able to use something like:
Select * from Win32_Printer where Local=true and Network=false and
(PortName like 'COM%' or PortName like 'LPT%' or PortName like 'USB%')
Well, not quite. It seems that there are a good number of virtual
printer drivers that needlessly claim to be on an LPT port, despite
their wholly virtual nature. (I've come across the "Time America PDF
Maker", for instance, which claims to be on LPT1:.)
Has anybody nailed this one down? It seems that there should be an
attribute bit somewhere that would unequivocally correlate with
whether a printer is physical or not.
date: Thu, 4 Sep 2008 13:51:15 -0700 (PDT)
author: Mr. Benjamin Strauss
Re: Enumerating Local Physical Printers
On Sep 4, 1:51 pm, "Mr. Benjamin Strauss" wrote:
> Although it seems like it should be quite simple, it turns out to be
> rather difficult to reliably enumerate only local physical printers on
> a machine. An obvious starting point would be something like:
> Select * from Win32_Printer where Local=true and Network=false
>
> The problem here is that many drivers, such as PDF and XPS document
> writers and fax drivers masquerading as printers are also turned up in
> such an enumeration.
>
> Alright, then, you say, we should at least be able to exclude fax
> drivers by looking at the PRINTER_ATTRIBUTE_FAX bit of the Attributes
> property? Well, sometimes, with some drivers.
>
> Okay, then, if we're willing to limit ourselves to COM, LPT and USB
> ports shouldn't we be able to use something like:
>
> Select * from Win32_Printer where Local=true and Network=false and
> (PortName like 'COM%' or PortName like 'LPT%' or PortName like 'USB%')
>
> Well, not quite. It seems that there are a good number of virtual
> printer drivers that needlessly claim to be on an LPT port, despite
> their wholly virtual nature. (I've come across the "Time America PDF
> Maker", for instance, which claims to be on LPT1:.)
>
> Has anybody nailed this one down? It seems that there should be an
> attribute bit somewhere that would unequivocally correlate with
> whether a printer is physical or not.
Hi,
Did you try using the following API to enumerate the
locally installed printers:
EnumPrinters()
http://msdn.microsoft.com/en-us/library/ms536005(VS.85).aspx
Kellie.
date: Fri, 5 Sep 2008 12:27:51 -0700 (PDT)
author: Kellie Fitton
Re: Enumerating Local Physical Printers
On Sep 5, 2:27 pm, Kellie Fitton wrote:
> On Sep 4, 1:51 pm, "Mr. Benjamin Strauss" wrote:
>
>
>
>
>
> > Although it seems like it should be quite simple, it turns out to be
> > rather difficult to reliably enumerate only localphysicalprinters on
> > a machine. An obvious starting point would be something like:
> > Select * fromWin32_Printerwhere Local=true and Network=false
>
> > The problem here is that many drivers, such as PDF and XPS document
> > writers and fax drivers masquerading as printers are also turned up in
> > such an enumeration.
>
> > Alright, then, you say, we should at least be able to exclude fax
> > drivers by looking at the PRINTER_ATTRIBUTE_FAX bit of the Attributes
> > property? Well, sometimes, with some drivers.
>
> > Okay, then, if we're willing to limit ourselves to COM, LPT and USB
> > ports shouldn't we be able to use something like:
>
> > Select * fromWin32_Printerwhere Local=true and Network=false and
> > (PortName like 'COM%' or PortName like 'LPT%' or PortName like 'USB%')
>
> > Well, not quite. It seems that there are a good number of virtual
> > printer drivers that needlessly claim to be on an LPT port, despite
> > their wholly virtual nature. (I've come across the "Time America PDF
> > Maker", for instance, which claims to be on LPT1:.)
>
> > Has anybody nailed this one down? It seems that there should be an
> > attribute bit somewhere that would unequivocally correlate with
> > whether a printer isphysicalor not.
>
> Hi,
>
> Did you try using the following API to enumerate the
> locally installed printers:
>
> EnumPrinters()
>
> http://msdn.microsoft.com/en-us/library/ms536005(VS.85).aspx
>
> Kellie.- Hide quoted text -
>
> - Show quoted text -
Yes, I've tried this (specifying PRINTER_ENUM_LOCAL) to no avail.
Such drivers as the "Send to OneNote 2007" and the "Microsoft XPS
Document Writer" are enumerated as though they were local printers.
By the way, I was really looking for a WMI approach to this. After
all, this is a WMI newsgroup.
date: Fri, 12 Sep 2008 06:31:16 -0700 (PDT)
author: Mr. Benjamin Strauss
|
|