WPF SDK研究 Printing (2) EnumerateSubsetOfPrintQueues

EnumerateSubsetOfPrintQueues
    shows how to use the EnumeratedPrintQueueTypes enumeration to get a subset of available print queues
    这个Sample倒也简单,只有一个Main函数,讲的是EnumeratedPrintQueueTypes枚举,通过其两个值Local和Shared将本地和共享的打印机全都找出来。

         static   void  Main( string [] args)
        
{
            
// Specify that the list will contain only the print queues that are installed as local and are shared
            EnumeratedPrintQueueTypes[] enumerationFlags = {EnumeratedPrintQueueTypes.Local,
                                                            EnumeratedPrintQueueTypes.Shared}
;

            LocalPrintServer printServer 
= new LocalPrintServer();

            
//Use the enumerationFlags to filter out unwanted print queues
            PrintQueueCollection printQueuesOnLocalServer = printServer.GetPrintQueues(enumerationFlags);

            Console.WriteLine(
"These are your shared, local print queues:\n\n");

            
foreach (PrintQueue printer in printQueuesOnLocalServer)
            
{
                Console.WriteLine(
"\tThe shared printer " + printer.Name + " is located at " + printer.Location + "\n");
            }

            Console.WriteLine(
"Press enter to continue.");
            Console.ReadLine();
        }

你可能感兴趣的:(Queue)