using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceProcess;
namespace JudgeSQLState
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public ServiceController getInstance()
{
return new ServiceController(txtSname.Text.Trim(), txtSaddr.Text.Trim());
}
private void btnShow_Click(object sender, EventArgs e)
{
if (getInstance().Status == ServiceControllerStatus.Running)
{
lblText.Text = "已打开";
}
}
private void btnStart_Click(object sender, EventArgs e)
{
if (getInstance().Status == ServiceControllerStatus.Stopped)
{
getInstance().Start();
lblText.Text = "已打开";
}
}
private void btnStop_Click(object sender, EventArgs e)
{
if (getInstance().Status == ServiceControllerStatus.Running)
{
getInstance().Stop();
lblText.Text = "已关闭";
}
}
}
}