#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