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
相關文章
相關標籤/搜索