Beispiel #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;
        }
Beispiel #2
0
        public bool Refresh()
        {
            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));
                Trace.TraceInformation("CurrentStatus as returned by QSSE = {0}", Status.CurrentState);
                return true;
            }
            Trace.WriteLine("ERROR, QueryServiceStatusEx() failed, aborting...");
            return false;
        }