示例#1
0
 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);
 }
示例#2
0
        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成功复位打印机,请检查是否可用!");
            }
        }
示例#3
0
 private void btnToolsRefreshServiceStatus_Click(object sender, EventArgs e)
 {
     this.lbToolsServiceStatus.Text = WindowServicesHelper.GetServiceState(this.txtToolsServiceName.Text.Trim());
 }
示例#4
0
 private void btnToolsPauseService_Click(object sender, EventArgs e)
 {
     WindowServicesHelper.Pause(this.txtToolsServiceName.Text.Trim());
 }