C# 清空电脑打印机队列

引入命名空间:

using System.Management;
using System.Printing;

            PrintQueue pq = localPrintServer.GetPrintQueue("PT561"); //电脑打印机的名字
            pq.Refresh();
            PrintJobInfoCollection allPrintJobs = pq.GetPrintJobInfoCollection();
            foreach (PrintSystemJobInfo printJob in allPrintJobs)
            {
                printJob.Cancel();

            }
posted @ 2021-09-01 22:13  墨苒孤  阅读(403)  评论(0)    收藏  举报