Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.


What I have tried:

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
Posted
Comments
Sissy Ram 3-Apr-18 8:47am    
Check whether rights given to access in server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900