Exemplo n.º 1
0
 public void Uninstall()
 {
     using (WinServiceNative native = new WinServiceNative())
     {
         native.Lock();
         native.Open(this.ServiceName);
         native.Delete();
     }
 }
Exemplo n.º 2
0
        public new void Stop()
        {
            using (WinServiceNative native = new WinServiceNative())
            {
                native.Lock();
                native.Open(this.ServiceName);

                ApiStructs.ServiceStatus ss = native.QueryStatus();
                if (ss.CurrentState != ApiEnums.ServiceState.SERVICE_RUNNING)
                {
                    throw new Win32Exception("Cannot start the service because it is not running");
                }
            }
        }
Exemplo n.º 3
0
        public void Install(string arguments)
        {
            string location = Assembly.GetEntryAssembly().Location;

            if (location.Contains(" "))
            {
                location = "\"" + location + "\"";
            }

            string imagePath = string.IsNullOrEmpty(arguments) ? location : string.Format("{0} {1}", location, arguments);

            ApiEnums.ServiceType serviceType = ApiEnums.ServiceType.SERVICE_WIN32_OWN_PROCESS;
            using (WinServiceNative native = new WinServiceNative())
            {
                native.Lock();
                native.Create(this.ServiceName, this.DisplayName, imagePath, serviceType);
            }
        }