コード例 #1
0
ファイル: ServiceStatus.cs プロジェクト: johnhk/pserv4
 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);
 }
コード例 #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));
 }
コード例 #3
0
ファイル: ServiceStatus.cs プロジェクト: johnhk/pserv4
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: ServiceDataObject.cs プロジェクト: jwg4/gtools
 public void UpdateFrom(SERVICE_STATUS_PROCESS ssp)
 {
     CurrentState     = ssp.CurrentState;
     ControlsAccepted = ssp.ControlsAccepted;
     SetNonZeroStringProperty("PID", ssp.ProcessID);
 }
コード例 #6
0
ファイル: ServiceDataObject.cs プロジェクト: johnhk/pserv4
 public void UpdateFrom(SERVICE_STATUS_PROCESS ssp)
 {
     CurrentState = ssp.CurrentState;
     ControlsAccepted = ssp.ControlsAccepted;
     SetNonZeroStringProperty("PID", ssp.ProcessID);
 }