1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Configuration.Install;
- using System.Linq;
- namespace LYFZ.WcfSystemService
- {
- [RunInstaller(true)]
- public partial class ProjectInstaller : System.Configuration.Install.Installer
- {
- public ProjectInstaller()
- {
- InitializeComponent();
-
- }
- private void ErpServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
- {
- System.ServiceProcess.ServiceController s = new System.ServiceProcess.ServiceController( LYFZ.WindowsServiceHandling.ServiceManagement.GetServiceName(LYFZ.WindowsServiceHandling.ServiceType.LYFZ_WcfSystmeService));
- SetServiceDesktopInsteract(s.ServiceName);
- if(s.Status==System.ServiceProcess.ServiceControllerStatus.Stopped){
- s.Start();
- }
-
-
- }
- #region 设置服务与桌面交互
-
-
-
-
-
- private void SetServiceDesktopInsteract(string serviceName)
- {
- System.Management.ManagementObject wmiService = new System.Management.ManagementObject(string.Format("Win32_Service.Name='{0}'", serviceName));
- System.Management.ManagementBaseObject changeMethod = wmiService.GetMethodParameters("Change");
- changeMethod["DesktopInteract"] = true;
- System.Management.ManagementBaseObject utParam = wmiService.InvokeMethod("Change", changeMethod,null);
- }
- #endregion
- }
- }
|