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 bool Refresh() { if (!Service.IsValid) { Log.WarnFormat("Warning, don't attempt to call QueryServiceStatusEx() on {0}", Service); return false; } int bytesNeeded; if (NativeServiceFunctions.QueryServiceStatusEx( Service.Handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO, Memory, Marshal.SizeOf(Status), out bytesNeeded)) { Status = (SERVICE_STATUS_PROCESS)Marshal.PtrToStructure( Memory, typeof(SERVICE_STATUS_PROCESS)); Log.InfoFormat("CurrentStatus as returned by QSSE = {0}", Status.CurrentState); return true; } return NativeHelpers.ReportFailure("QueryServiceStatusEx({0})", Service); }
public bool Refresh() { if (!Service.IsValid) { Log.WarnFormat("Warning, don't attempt to call QueryServiceStatusEx() on {0}", Service); return(false); } int bytesNeeded; if (NativeServiceFunctions.QueryServiceStatusEx( Service.Handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO, Memory, Marshal.SizeOf(Status), out bytesNeeded)) { Status = (SERVICE_STATUS_PROCESS)Marshal.PtrToStructure( Memory, typeof(SERVICE_STATUS_PROCESS)); Log.InfoFormat("CurrentStatus as returned by QSSE = {0}", Status.CurrentState); return(true); } return(NativeHelpers.ReportFailure("QueryServiceStatusEx({0})", Service)); }
public void UpdateFrom(SERVICE_STATUS_PROCESS ssp) { CurrentState = ssp.CurrentState; ControlsAccepted = ssp.ControlsAccepted; SetNonZeroStringProperty("PID", ssp.ProcessID); }