Member 10663078 Ответов: 0

Как получить удаленно установленный принтер и его лоток(источник бумаги) в VB.NET


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

Sissy Ram

Проверьте, предоставлены ли права на доступ к серверу

0 Ответов