コード例 #1
0
 private void ServiceStop()
 {
     this.Cursor = Cursors.WaitCursor;
     if (ServiceMgt.SetServiceStatus(_hostInfo.ServiceName, ServiceStatus.Stopped, Program.Log))
     {
         RefreshServiceStatus(ServiceStatus.Stopped);
     }
     this.Cursor = Cursors.Default;
 }
コード例 #2
0
 private void buttonSvcStopLocal_Click(object sender, EventArgs e)
 {
     MessageBox.Show(
         ServiceMgt.SetServiceStatus(
             this.textBoxNTServiceName.Text.Trim(),
             ServiceStatus.Stopped,
             Program.Log).ToString()
         );
 }
コード例 #3
0
        public bool SetServiceStatusAndStartStyle(string name, ServiceStatus status)
        {
            bool res = ServiceMgt.SetServiceStatus(name, status, Program.Log);

            if (res)
            {
                switch (status)
                {
                case ServiceStatus.Running:
                    res = ServiceMgt.SetServiceStartStyle(name, ServiceMgt.Automatic, Program.Log);
                    break;

                case ServiceStatus.Stopped:
                    res = ServiceMgt.SetServiceStartStyle(name, ServiceMgt.Manual, Program.Log);
                    break;
                }
            }

            return(res);
        }