//启动服务
private void btnStar_Click(object sender, EventArgs e)
{
if (bolServiceInstalled == false)
return;
using (System.ServiceProcess.ServiceController control = new ServiceController("Project Monitoring"))
{
if (control.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
{
MessageBox.Show("服务启动......");
control.Start();
lblMessage.Text = "服务已经启动......";
}
}
}
//停止服务
private void btnStop_Click(object sender, EventArgs e)
{
if (bolServiceInstalled == false)
return;
using (System.ServiceProcess.ServiceController control = new ServiceController("Project Monitoring"))
{
if (control.Status == System.ServiceProcess.ServiceControllerStatus.Running)
{
MessageBox.Show("服务停止......");
control.Stop();
lblMessage.Text = "服务已经停止......";
}
}
}
private void btnStar_Click(object sender, EventArgs e)
{
if (bolServiceInstalled == false)
return;
using (System.ServiceProcess.ServiceController control = new ServiceController("Project Monitoring"))
{
if (control.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
{
MessageBox.Show("服务启动......");
control.Start();
lblMessage.Text = "服务已经启动......";
}
}
}
//停止服务
private void btnStop_Click(object sender, EventArgs e)
{
if (bolServiceInstalled == false)
return;
using (System.ServiceProcess.ServiceController control = new ServiceController("Project Monitoring"))
{
if (control.Status == System.ServiceProcess.ServiceControllerStatus.Running)
{
MessageBox.Show("服务停止......");
control.Stop();
lblMessage.Text = "服务已经停止......";
}
}
}