예제 #1
0
        public static NativeMethods.ServiceStatusInfo ReadServiceStatus(SafeServiceHandle serviceHandle)
        {
            NativeMethods.ServiceStatusInfo ServiceStatus = default;

            if (!NativeMethods.QueryServiceStatus(serviceHandle, ref ServiceStatus))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            return(ServiceStatus);
        }
예제 #2
0
파일: Service.cs 프로젝트: uzbekdev1/core-1
        private void ControlService(uint dwAccess, uint dwControl)
        {
            using SafeServiceHandle ServiceManager = ServiceHelper.OpenServiceManager(
                      MachineName,
                      NativeMethods.SC_MANAGER_CONNECT);

            using SafeServiceHandle ServiceHandle = ServiceHelper.OpenService(
                      ServiceManager,
                      ServiceName,
                      dwAccess);

            NativeMethods.ServiceStatusInfo Status = default;

            if (!NativeMethods.ControlService(ServiceHandle, dwControl, ref Status))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            State = Status.dwCurrentState;
        }
예제 #3
0
파일: Service.cs 프로젝트: uzbekdev1/core-1
        private void RefreshStatus(SafeServiceHandle serviceHandle)
        {
            NativeMethods.ServiceStatusInfo Status = ServiceHelper.ReadServiceStatus(serviceHandle);

            State = Status.dwCurrentState;
        }