C# Windows服务相关

代码及注释

            ServiceController sc = new ServiceController("gupdatem");
            sc.Stop();//停止服务
            sc.Start();//开始
            sc.Status.ToString();//运行状态;
            
            
            RegistryKey rk =Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\360AntiHacker");
            if (rk!=null)
            {
                rk.GetValue("imagePath").ToString();//取服务路径
                rk.GetValue("Start").ToString();//服务运行方式  1,2,3,4  没有方式 自动 手动 禁用
            }

猜你喜欢

转载自www.cnblogs.com/SoftWareIe/p/8875041.html
今日推荐