Esempio n. 1
0
        public bool Control(SC_CONTROL_CODE code)
        {
            if (NativeServiceFunctions.ControlService(Service.Handle, code, Memory))
            {
                Status = (SERVICE_STATUS_PROCESS)Marshal.PtrToStructure(
                    Memory,
                    typeof(SERVICE_STATUS_PROCESS));
                Trace.TraceInformation("Currentstatus = {0}", Status.CurrentState);
                return true;
            }
            Trace.TraceInformation("ERROR, unable to set control {0} for service {1}",
                Marshal.GetLastWin32Error(), Service.Description);

            return false;
        }
Esempio n. 2
0
 public bool Control(SC_CONTROL_CODE code)
 {
     if (!Service.IsValid)
     {
         Log.WarnFormat("Warning, don't attempt to call Control({1}) on {0}", Service, code);
         return false;
     }
     Log.InfoFormat("ControlService({0}, {1})", Service, code);
     if (NativeServiceFunctions.ControlService(Service.Handle, code, Memory))
     {
         Status = (SERVICE_STATUS_PROCESS)Marshal.PtrToStructure(
             Memory,
             typeof(SERVICE_STATUS_PROCESS));
         Log.InfoFormat("Currentstatus = {0}", Status.CurrentState);
         return true;
     }
     return NativeHelpers.ReportFailure("ControlService({0}, {1})", Service, code);
 }
Esempio n. 3
0
 public bool Control(SC_CONTROL_CODE code)
 {
     if (!Service.IsValid)
     {
         Log.WarnFormat("Warning, don't attempt to call Control({1}) on {0}", Service, code);
         return(false);
     }
     Log.InfoFormat("ControlService({0}, {1})", Service, code);
     if (NativeServiceFunctions.ControlService(Service.Handle, code, Memory))
     {
         Status = (SERVICE_STATUS_PROCESS)Marshal.PtrToStructure(
             Memory,
             typeof(SERVICE_STATUS_PROCESS));
         Log.InfoFormat("Currentstatus = {0}", Status.CurrentState);
         return(true);
     }
     return(NativeHelpers.ReportFailure("ControlService({0}, {1})", Service, code));
 }
Esempio n. 4
0
 public static unsafe extern bool ControlService(
     IntPtr serviceHandle,
     SC_CONTROL_CODE control,
     IntPtr buffer);
Esempio n. 5
0
 public static extern unsafe bool ControlService(
     IntPtr serviceHandle,
     SC_CONTROL_CODE control,
     IntPtr buffer);