Actually i want to get all Printer Installed in Application Server. I use the Following Code. it Will Work in localhost. But when Service host In Windows Server 2012 R2 Then Remotely Installed Printer's tray can't get.
Public Function AppServerPrinterList() As ArrayList Implements IService.AppServerPrinterList Dim lst As New ArrayList Dim myPrintDocument As System.Drawing.Printing.PrintDocument = New System.Drawing.Printing.PrintDocument Dim selectedPaperSource As System.Drawing.Printing.PaperSource = New System.Drawing.Printing.PaperSource Dim myPrinterSettings As System.Drawing.Printing.PrinterSettings = New System.Drawing.Printing.PrinterSettings() Dim strValue As String 'Add All Installed Printers to List For Each strPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters 'Check Default Printer. If strPrinter = myPrintDocument.PrinterSettings.PrinterName Then strValue = strPrinter.ToString & "_def" Else strValue = strPrinter.ToString End If lst.Add(strValue) 'Add PaperSource of All Printer myPrinterSettings.PrinterName = strPrinter For Each myPaperSource As System.Drawing.Printing.PaperSource In myPrinterSettings.PaperSources If myPaperSource.SourceName <> "" Then 'Check Default PaperSource. If strPrinter = myPrintDocument.PrinterSettings.PrinterName AndAlso myPrintDocument.PrinterSettings.DefaultPageSettings.PaperSource.SourceName = myPaperSource.SourceName Then strValue = "tvcnode_" & strPrinter & "!" & myPaperSource.SourceName & "_def" Else strValue = "tvcnode_" & strPrinter & "!" & myPaperSource.SourceName End If lst.Add(strValue) End If Next Next myPrintDocument.Dispose() myPrintDocument = Nothing myPrinterSettings = Nothing Return lst End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)