I need a list of printers that DO NOT print direct. Getting a list that do print direct seems reasonably easy. But how to do the opposite?
Dim PrintServer As New SysPrint.PrintServer
Dim arrFlags(0) As SysPrint.EnumeratedPrintQueueTypes
arrFlags(0) = System.Printing.EnumeratedPrintQueueTypes.DirectPrinting
Dim QColl As SysPrint.PrintQueueCollection = PrintServer.GetPrintQueues(arrFlags)
PrintServer.GetPrintQueues Method
EnumeratedPrintQueueTypes Enumeration
MSDN says that the EnumeratedPrintQueueTypes has a FlagsAttribute attribute that allows a bitwise combination of its member values. So I should be able to specify NOT direct somehow. How do I do it?
I tried to do this arrFlags(0) = Not System.Printing.EnumeratedPrintQueueTypes.DirectPrinting
but that returned no results. Clearly incorrect.
So how do I manipulate the flags attribute to eliminate all printers printing direct?
This is one way to do it but it seems very inelegant:
'get full list
Dim PrintServer As New SysPrint.PrintServer
Dim QColl As SysPrint.PrintQueueCollection = PrintServer.GetPrintQueues()
'get those not printing direct
Dim Qcoll2 As List(Of SysPrint.PrintQueue) = QColl.Where(Function(x) Not (x.IsDirect)).ToList
'select name only
Dim strList As List(Of String) = Qcoll2.Select(Function(x) x.Name).ToList