首页 > 代码库 > Printer Print Queue
Printer Print Queue
- PrinterServer:在打印服务器上管理打印队列。View Code
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();
- 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。