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();
}