更简单的:
//启动服务
protected override void OnStart(string[] args)
{
WriteToLog("服务启动","");
try
{
NewActiveReport2 rpt = new NewActiveReport2();
rpt.Run();
rpt.Document.Printer.PrinterName = "pdfFactory Pro";
rpt.Document.Print(false, false, false);
WriteToLog("打印成功", "");
}
catch (Exception ex)
{
WriteToLog("打印出错", ex.Message);
}
}
日志显示:
服务启动
打印成功
关键是打印机仍然没有反应。 |