示例#1
0
 private void 启动ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ClServCtl.RunService(ServiceName))
     {
         MessageBox.Show("启动/重启操作失败");
     }
 }
示例#2
0
        private void 打开执行文件目录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filepath = "";
            string filename = ClServCtl.GetFilePath(ServiceName);

            if (filename == "")
            {
                MessageBox.Show("操作失败,没有找到路径");
                return;
            }
            for (int i = filename.Length - 1; i > 0; i--)
            {
                if (filename.Substring(i, 1) == @"\")
                {
                    filepath = filename.Substring(0, i);
                    break;
                }
            }
            try
            {
                System.Diagnostics.Process.Start("explorer.exe", filepath);
            }
            catch
            {
                MessageBox.Show("操作失败,没有找到合法路径");
            }
        }
示例#3
0
 private void 恢复暂停ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ClServCtl.ResumeService(ServiceName))
     {
         MessageBox.Show("恢复暂停操作失败");
     }
 }
示例#4
0
 private void 停止ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!ClServCtl.StopService(ServiceName))
     {
         MessageBox.Show("停止操作失败");
     }
 }
示例#5
0
 private void 添加到系统启动项ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ClServCtl.SetAutoRun("AutoRun" + ServiceName, Application.ExecutablePath))
     {
         MessageBox.Show("操作成功");
     }
     else
     {
         MessageBox.Show("操作失败");
     }
 }
示例#6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string ServState = ClServCtl.GetServState(ServiceName);
            string RunType   = ClServCtl.GetServRunType(ServiceName);

            switch (ServState)
            {
            case "":   //没有服务
                notifyIcon1.Icon = icohui;
                notifyIcon1.Text = "没有找到服务:" + ServiceName;
                break;

            case "Stopped":    //停止
                notifyIcon1.Icon = icohong;
                notifyIcon1.Text = ServiceName + " 服务已停止(" + RunType + ")";
                break;

            case "Running":    //运行
                notifyIcon1.Icon = icolv;
                notifyIcon1.Text = ServiceName + " 服务正在运行(" + RunType + ")";
                break;

            case "StartPending":    //正在启动
                notifyIcon1.Icon = icolv;
                notifyIcon1.Text = ServiceName + " 服务正在尝试启动(" + RunType + ")";
                break;

            case "StopPending":    //正在停止
                notifyIcon1.Icon = icohong;
                notifyIcon1.Text = ServiceName + " 服务正在尝试停止(" + RunType + ")";
                break;

            case "Paused":
                notifyIcon1.Icon = icohong;
                notifyIcon1.Text = ServiceName + " 服务已暂停(" + RunType + ")";
                break;

            case "PausePending":
                notifyIcon1.Icon = icohong;
                notifyIcon1.Text = ServiceName + " 服务正在尝试暂停(" + RunType + ")";
                break;

            case "ContinuePending":
                notifyIcon1.Icon = icohong;
                notifyIcon1.Text = ServiceName + " 服务正在尝试恢复运行(" + RunType + ")";
                break;
            }
        }
示例#7
0
 private void 禁用ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ClServCtl.SetServRunType(ServiceName, 4);
 }
示例#8
0
 private void 取消系统启动项ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ClServCtl.DeleteAutoRun("AutoRun" + ServiceName);
 }