- Printerserver: Manage the print queue on the print server.
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: Manage printers and print jobs
- Printsystemjobinfo: detailed definition of the print job
- Printjobstatus: Specifies the current status of the job in the print queue.
- Printqueuestatus: Specifies the status of the print queue or its printer.
- Printqueue. queuestatus: gets the value used to indicate the printer status. These statuses include "pushing", "Initializing", and "printing.
Example:
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 {1 6 _ printqueue = PQ; 17} 18} 19} 20 21 public bool isprinted22 {23 get24 {25 return checkisprinted (_ printqueue ); 26} 27} 28 29 /// <summary> 30 // check whether the print queue is printed. 31 /// </Summary> 32 /// <Param name = "PQ "> print queue </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