Re: InstalledPrinters and Windows Server 2003 R2

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for your help Duncan. I decided to try what you have suggested using
the EnumPrinters API but I am having problems getting this API to work on the
Server 2003 R2 box. It works fine on XP. When the following code gets to
the EnumPrinters line it just stops and does not return an error. Am I using
the wrong lib for 2003 R2?

Private Declare Function EnumPrinters Lib "winspool.drv" Alias
"EnumPrintersA" (ByVal flags As Integer, ByVal name As String, ByVal Level As
Integer, ByRef pPrinterEnum As Integer, ByVal cdBuf As Integer, ByRef
pcbNeeded As Integer, ByRef pcReturned As Integer) As Integer

Private Structure PRINTER_INFO_4
Dim pPrinterName As String
Dim pServerName As String
Dim Attributes As Integer
End Structure

Dim PrinterEnum() As PRINTER_INFO_4, FNLoop As Integer = 0,
PRINTER_ENUM_LOCAL = &H2, pPrinterEnum() As Integer, cdBuf As Integer =
10000, pcbNeeded As Integer, pcReturned As Integer, ReturnValue As Integer
ReDim pPrinterEnum(0 To cdBuf / 4)

ReturnValue = EnumPrinters(PRINTER_ENUM_LOCAL, "", 4, pPrinterEnum(0),
cdBuf, pcbNeeded, pcReturned)

Thanks,
Marc


"Duncan Jones" wrote:

Hi

I found that InstalledPrinters had problems when one or more printers had
different permissions to the others
I had to fall back on the EnumPrinters API. Maybe make sure that the user
running the code has the same permissions on all the printers?

Hope this helps,
Duncan


"Marc" <Marc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CBCE03DA-AD1D-4190-BDD9-5580493C1F0B@xxxxxxxxxxxxxxxx
I am using VB 2005 to get the printers that have been installed on a
Windows
Server 2003 R2 box. I would like to write these printers into a table in
SQL
Server. The problem is when I run the code using:
System.Drawing.Printing.PrinterSettings.InstalledPrinters and count and
item no printers are found. Printers are installed on the server and when
I
run the same code on a Win XP box all installed printers are listed.
Anyone
have any idea why the 2003 R2 box does not return the installed printers?
Any help would be greatly appreciated.
Marc

.



Relevant Pages

  • Re: Windows CE + EnumPrinters
    ... EnumPrinters() is not supported on CE. ... I am newbie in Windows CE Developement, I am writing a very simple ... printers installed on machine, For that I am using EnumPrinters API, I ... What I need to do to enumerate printers ...
    (microsoft.public.windowsce.embedded.vc)
  • EnumPrinters PRINTER_ATTRIBUTE_LOCAL
    ... I'm calling the EnumPrinters() api with various info levels 1,2,4,5. ... I am testing on a Workgroup configuration -- not a domain. ... And it identifies the location of the printers correctly. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Is there something better than EnumPrinters?
    ... Checkout msdn and there are samples out there which you can take and use. ... Vipin Aravind ... > information on all the printers currently installed than EnumPrinters. ...
    (microsoft.public.vc.mfc)
  • Re: Win32::Printer::Enum::Printer($server)
    ... > priv at MYBOX). ... > Looking at MSDN it implies that the parameter to EnumPrinters() should ... In the Printers() function I see the following code: ...
    (comp.lang.perl.modules)
  • Re: How can I search through installed printers and select one?
    ... installed printers. ... EnumPrinters looks like a good starting point. ... the existence of EnumDisplayDevices, and of course got no hits. ...
    (microsoft.public.vc.mfc)