标签:style blog http color os io ar for art
1 // Create a PrintServer 2 // "theServer" must be a print server to which the user has full print access. 3 PrintServer myPrintServer = new PrintServer(@"\\theServer"); 4 5 // List the print server‘s queues 6 PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues(); 7 String printQueueNames = "My Print Queues:\n\n"; 8 foreach (PrintQueue pq in myPrintQueues) 9 { 10 printQueueNames += "\t" + pq.Name + "\n"; 11 } 12 Console.WriteLine(printQueueNames); 13 Console.WriteLine("\nPress Return to continue."); 14 Console.ReadLine();
示例:
1 public class SystemPrintQueue 2 { 3 private string _printerName; 4 private string _owner; 5 private PrintQueue _printQueue; 6 7 public SystemPrintQueue(string printerName) 8 { 9 _printerName = printerName; 10 _owner = System.Environment.UserName; 11 PrintServer server = new PrintServer(printerName); 12 foreach (PrintQueue pq in server.GetPrintQueues()) 13 { 14 if (pq.FullName.Equals(printerName)) 15 { 16 _printQueue = pq; 17 } 18 } 19 } 20 21 public bool IsPrinted 22 { 23 get 24 { 25 return CheckIsPrinted(_printQueue); 26 } 27 } 28 29 /// <summary> 30 /// 检测打印队列是否打印完成 31 /// </summary> 32 /// <param name="pq">打印队列</param> 33 /// <returns></returns> 34 private bool CheckIsPrinted(PrintQueue pq) 35 { 36 bool isPrinted = false; 37 if (pq != null) 38 { 39 pq.Refresh(); 40 PrintJobInfoCollection jobs = pq.GetPrintJobInfoCollection(); 41 if (jobs != null && jobs.Count() > 0) 42 { 43 isPrinted = jobs.All<PrintSystemJobInfo>(job => job.Submitter == System.Environment.UserName && (job.JobStatus & PrintJobStatus.Paused) == PrintJobStatus.Paused); 44 } 45 else 46 { 47 isPrinted = true; 48 } 49 } 50 return isPrinted; 51 } 52 }
标签:style blog http color os io ar for art
原文地址:http://www.cnblogs.com/JustYong/p/3958423.html