--- title: "How to: Enumerate a Subset of Print Queues" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "enumerating [WPF], subset of print queues" - "print queues [WPF], enumerating subset of" ms.assetid: 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 method of a object and the 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 enumeration provides many other possibilities. The code then creates a object, a class derived from . The local print server is the computer on which the application is running. The last significant step is to pass the array to the method. Finally, the results are presented to the user. [!code-cpp[EnumerateSubsetOfPrintQueues#ListSubsetOfPrintQueues](~/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/Program.cpp#listsubsetofprintqueues)] [!code-csharp[EnumerateSubsetOfPrintQueues#ListSubsetOfPrintQueues](~/samples/snippets/csharp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CSharp/Program.cs#listsubsetofprintqueues)] [!code-vb[EnumerateSubsetOfPrintQueues#ListSubsetOfPrintQueues](~/samples/snippets/visualbasic/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/visualbasic/program.vb#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 method and test the returned value for the presence of duplexing. ## See also - - - - - - - [Documents in WPF](documents-in-wpf.md) - [Printing Overview](printing-overview.md) - [Microsoft XPS Document Writer](/windows/win32/printdocs/microsoft-xps-document-writer)