C#打印,以及打印之前测试打印机是否已准备好.

时间:2012-01-27 05:20:19
【文件属性】:

文件名称:C#打印,以及打印之前测试打印机是否已准备好.

文件大小:1KB

文件格式:TXT

更新时间:2012-01-27 05:20:19

C#打印

public string GetPrinterStatus() { string printStatus = "No default printer installed"; ManagementObjectCollection printers = new ManagementClass("Win32_Printer").GetInstances(); foreach (ManagementObject printer in printers) { switch (printer["PrinterStatus"].ToString()) { case "1": printStatus = "Other"; break; case "2": printStatus = "Unknown"; break; case "3": printStatus = "Idle"; break; case "4": printStatus = "Printing"; break; case "5": printStatus = "Warmup"; break; case "6": printStatus = "Stopped"; break; case "7": printStatus = "Offline"; break; } // } } // this.PrinterStatus = printStatus; return printStatus; } private void printToolStripMenuItem_Click(object sender, EventArgs e) { SendKeys.Send("%{PRTSC}"); string aa = GetPrinterStatus(); Application.DoEvents();//Processes all Windows messages currently in the message queue if (aa == "Idle") { this.printDocument1.Print(); } else { MessageBox.Show("Please check whether your printer is ready."); } }


网友评论

  • 测试通过,可以的