* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.8 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|
| How to: Enumerate a Subset of Print Queues | 03/30/2017 |
|
|
cc4a1b5b-d46f-4c5e-bc26-22c226e4bee0 |
How to: Enumerate a Subset of Print Queues
A common situation faced by information technology (IT) professionals managing a company-wide set of printers is to generate a list of printers having certain characteristics. This functionality is provided by the xref:System.Printing.PrintServer.GetPrintQueues%2A method of a xref:System.Printing.PrintServer object and the xref:System.Printing.EnumeratedPrintQueueTypes enumeration.
Example
In the example below, the code begins by creating an array of flags that specify the characteristics of the print queues we want to list. In this example, we are looking for print queues that are installed locally on the print server and are shared. The xref:System.Printing.EnumeratedPrintQueueTypes enumeration provides many other possibilities.
The code then creates a xref:System.Printing.LocalPrintServer object, a class derived from xref:System.Printing.PrintServer. The local print server is the computer on which the application is running.
The last significant step is to pass the array to the xref:System.Printing.PrintServer.GetPrintQueues%2A method.
Finally, the results are presented to the user.
[!code-cppEnumerateSubsetOfPrintQueues#ListSubsetOfPrintQueues] [!code-csharpEnumerateSubsetOfPrintQueues#ListSubsetOfPrintQueues] [!code-vbEnumerateSubsetOfPrintQueues#ListSubsetOfPrintQueues]
You could extend this example by having the foreach loop that steps through each print queue do further screening. For example, you could screen out printers that do not support two-sided printing by having the loop call each print queue's xref:System.Printing.PrintQueue.GetPrintCapabilities%2A method and test the returned value for the presence of duplexing.
See also
- xref:System.Printing.PrintServer.GetPrintQueues%2A
- xref:System.Printing.PrintServer
- xref:System.Printing.LocalPrintServer
- xref:System.Printing.EnumeratedPrintQueueTypes
- xref:System.Printing.PrintQueue
- xref:System.Printing.PrintQueue.GetPrintCapabilities%2A
- Documents in WPF
- Printing Overview
- Microsoft XPS Document Writer