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; }
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); }
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)); }
public static unsafe extern bool ControlService( IntPtr serviceHandle, SC_CONTROL_CODE control, IntPtr buffer);
public static extern unsafe bool ControlService( IntPtr serviceHandle, SC_CONTROL_CODE control, IntPtr buffer);