標籤:style blog http color os io ar for art
- PrinterServer:在列印伺服器上管理列印佇列。
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();View Code
- PrintQueue:管理印表機與列印工作
- PrintSystemJobInfo:詳細定義列印工作
- PrintJobStatus:指定列印佇列中列印工作的目前狀態。
- PrintQueueStatus:指定列印佇列或其印表機的狀態。
- PrintQueue.QueueStatus:擷取用於表示印表機狀態的值。 這些狀態包括“正在預熱”、“正在初始化”、“正在列印”等。
樣本:
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 IsPrinted22 {23 get24 {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 else46 {47 isPrinted = true;48 }49 }50 return isPrinted;51 }52 }
Printer Print Queue