引入命名空间:
using System.Management;
using System.Printing;
PrintQueue pq = localPrintServer.GetPrintQueue("PT561"); //电脑打印机的名字 pq.Refresh(); PrintJobInfoCollection allPrintJobs = pq.GetPrintJobInfoCollection(); foreach (PrintSystemJobInfo printJob in allPrintJobs) { printJob.Cancel(); }