/// <summary> /// 程序启动检查打印的Windows服务是否启动 /// </summary> static void CheckPrinterWindowsServer() { var result = PrinterHelper.CheckServerState("RpcSs"); var result1 = PrinterHelper.CheckServerState("Spooler"); if (result != "服务已经启动") { PrinterHelper.StartWindowsServer("RpcSs"); } if (result1 != "服务已经启动") { PrinterHelper.StartWindowsServer("Spooler"); } }
/// <summary> /// 打印机开始打印 /// </summary> void ReportPrintBegin() { string alertInfo = _report.Printer.PrinterName + "正在打印" + _list.Count + "条打印记录,已经提交给打印机,提交时间:" + DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat); // 检查打印服务是否启动了,很多的Ghost版本的windows操作系统把这服务关闭了,导致没办法打印,程序会异常 var result = PrinterHelper.CheckServerState("RpcSs"); var result1 = PrinterHelper.CheckServerState("Spooler"); if (result != "服务已经启动" || result1 != "服务已经启动") { XtraMessageBox.Show("系统RpcSs或则Spooler两个打印服务未启动", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); } // 显示打印机状态 var printerStatus = STO.Print.Utilities.PrinterHelperExtend.Printer.GetPrinterStatus(_report.Printer.PrinterName); string alertInfo1 = _report.Printer.PrinterName + "打印机状态:" + printerStatus; STO.Print.Utilities.PrinterHelper.OpenPrinterStatusWindow(_report.Printer.PrinterName); }