public MonitorServiceInfo(string system, string systemVersion, ServiceController control) { this.System = system; this.SystemVersion = systemVersion; this.ServiceName = control.DisplayName; this.ServicePath = control.ServiceName; this.StartType = control.ServiceType.ToString(); this.State = WindowServicesHelper.TransServiceState(control); }
private void button1_Click(object sender, EventArgs e) { PrinterStatus status = WindowsPrinterHelper.GetPrinterStat(); this.txtLog.AppendText("\r\n获取打印机状态结果为:" + status.ToString()); if (status == PrinterStatus.其他状态) { string service = "Spooler"; //spool\PRINTERS this.txtLog.AppendText("\r\n开始停止打印服务"); WindowServicesHelper.ForceStop(service); this.txtLog.AppendText("\r\n成功停止打印服务,请等待4-5秒"); System.Threading.Thread.Sleep(3000); this.txtLog.AppendText("\r\n开始删除打印缓存"); WindowsPrinterHelper.DeleteAllSpooler(); this.txtLog.AppendText("\r\n开始启动打印服务"); WindowServicesHelper.ForceStart(service); this.txtLog.AppendText("\r\n成功启动打印服务"); this.txtLog.AppendText("\r\n成功复位打印机,请检查是否可用!"); } }
private void btnToolsRefreshServiceStatus_Click(object sender, EventArgs e) { this.lbToolsServiceStatus.Text = WindowServicesHelper.GetServiceState(this.txtToolsServiceName.Text.Trim()); }
private void btnToolsPauseService_Click(object sender, EventArgs e) { WindowServicesHelper.Pause(this.txtToolsServiceName.Text.Trim()); }