private void Form1_Load(object sender, EventArgs e) { getSystemPrinters(); } private void getSystemPrinters() { LocalPrintServer ps = new LocalPrintServer(); PrintQueueCollection pqc = ps.GetPrintQueues(); foreach (PrintQueue pq in pqc) { comboBoxDefaultPrinter.Items.Add(pq.FullName); comboBoxPrinter2.Items.Add(pq.FullName); } if (comboBoxDefaultPrinter.Items.Count > 0) comboBoxDefaultPrinter.SelectedIndex = 2; comboBoxPrinter2.SelectedIndex = 3; } private void btnInitialQueue_Click(object sender, EventArgs e) { LocalPrintServer server = new LocalPrintServer(); PrintQueueCollection queueCollection = server.GetPrintQueues(); PrintQueue pq1 = server.GetPrintQueue(comboBoxDefaultPrinter.Text); PrintQueue pq2 = server.GetPrintQueue(comboBoxPrinter2.Text); ListBoxDefaultPrinterQueue.Items.Clear(); pq1.Refresh(); PrintJobInfoCollection jobs1 = pq1.GetPrintJobInfoCollection(); foreach (PrintSystemJobInfo job in jobs1) ListBoxDefaultPrinterQueue.Items.Add(job.JobIdentifier.ToString() + " : " + job.Name + " | " + job.JobStatus.ToString() + " | " + job.JobSize / 1024 + " KByte"); ListBoxPrinter2Queue.Items.Clear(); pq2.Refresh(); PrintJobInfoCollection jobs2 = pq2.GetPrintJobInfoCollection(); foreach (PrintSystemJobInfo job in jobs2) ListBoxPrinter2Queue.Items.Add(job.JobIdentifier.ToString() + " : " + job.Name + " | " + job.JobStatus.ToString() + " | " + job.JobSize / 1024 + " KByte"); } private void btnCopyQueue_Click(object sender, EventArgs e) { LocalPrintServer server = new LocalPrintServer(); PrintQueue DefaultPrinterQueue = server.GetPrintQueue(comboBoxDefaultPrinter.Text); PrintQueue Printer2Queue=server.GetPrintQueue(comboBoxPrinter2.Text); ListBoxPrinter2Queue.Items.Clear(); PrintJobInfoCollection jobs = DefaultPrinterQueue.GetPrintJobInfoCollection(); foreach (PrintSystemJobInfo job in jobs) Printer2Queue.AddJob(job.Name); // this Code Not work PrintJobInfoCollection jobs2 = Printer2Queue.GetPrintJobInfoCollection(); foreach (PrintSystemJobInfo job in jobs2) ListBoxPrinter2Queue.Items.Add(job.JobIdentifier.ToString() + " : " + job.Name + " " + job.JobStatus.ToString() + " | " + job.JobSize / 1024 + " KByte"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)