Re: InstalledPrinters and Windows Server 2003 R2
- From: Marc <Marc@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 28 Jul 2008 10:13:10 -0700
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
- Follow-Ups:
- Re: InstalledPrinters and Windows Server 2003 R2
- From: Duncan Jones
- Re: InstalledPrinters and Windows Server 2003 R2
- References:
- Re: InstalledPrinters and Windows Server 2003 R2
- From: Duncan Jones
- Re: InstalledPrinters and Windows Server 2003 R2
- Prev by Date: Re: Deploy app with MS Interop...
- Next by Date: Re: Screen2Video
- Previous by thread: Re: InstalledPrinters and Windows Server 2003 R2
- Next by thread: Re: InstalledPrinters and Windows Server 2003 R2
- Index(es):
Relevant Pages
|