C#windows service效劳装置、注册、判别效劳能否存在、能否发动

#region Windows效劳控制区

        #region 装置效劳
        private void InstallService(IDictionary stateSaver, string filepath)
        {
            try
            {
                ServiceController http://www.kp1111.info/linked/20130312.do  service = new ServiceController("ServiceName");
                if (!ServiceIsExisted("ServiceName"))
                {
                    //Install Service
                    AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
                    myAssemblyInstaller.UseNewContext = true;
                    myAssemblyInstaller.Path = filepath;
                    myAssemblyInstaller.Install(stateSaver);
                    myAssemblyInstaller.Commit(stateSaver);
                    myAssemblyInstaller.Dispose();
                    //--Start Service
                    service.Start();
                }
                else
                {
                    if (service.Status != System.ServiceProcess.ServiceControllerStatus.Running  http://www.aaafaipiao.com/linked/20130312.do

你可能感兴趣的:(C#windows service效劳装置、注册、判别效劳能否存在、能否发动)