如何获取不直接打印的打印机列表?
How to get list of printers not printing direct?
我需要一份不直接打印的打印机列表。获得一份直接打印的清单似乎相当容易。但是如何反其道而行之呢?
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 说 EnumeratedPrintQueueTypes 有一个 FlagsAttribute 属性,允许对其成员值进行按位组合。所以我应该能够以某种方式指定 NOT direct。我该怎么做?
我尝试这样做 arrFlags(0) = Not System.Printing.EnumeratedPrintQueueTypes.DirectPrinting
但没有返回任何结果。明显不正确。
那么如何操作标志属性来消除所有打印机直接打印?
这是一种方法,但看起来很不优雅:
'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
我需要一份不直接打印的打印机列表。获得一份直接打印的清单似乎相当容易。但是如何反其道而行之呢?
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 说 EnumeratedPrintQueueTypes 有一个 FlagsAttribute 属性,允许对其成员值进行按位组合。所以我应该能够以某种方式指定 NOT direct。我该怎么做?
我尝试这样做 arrFlags(0) = Not System.Printing.EnumeratedPrintQueueTypes.DirectPrinting
但没有返回任何结果。明显不正确。
那么如何操作标志属性来消除所有打印机直接打印?
这是一种方法,但看起来很不优雅:
'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