当前位置: 首页>>代码示例>>C#>>正文


C# SERVICE_STATUS类代码示例

本文整理汇总了C#中SERVICE_STATUS的典型用法代码示例。如果您正苦于以下问题:C# SERVICE_STATUS类的具体用法?C# SERVICE_STATUS怎么用?C# SERVICE_STATUS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SERVICE_STATUS类属于命名空间,在下文中一共展示了SERVICE_STATUS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ErrorExit

 public static void ErrorExit(ILog log, IntPtr serviceHandle, UInt32 serviceSpecificExitCode)
 {
     var status = new SERVICE_STATUS
     {
         dwServiceType             = SERVICE_TYPES.SERVICE_WIN32_OWN_PROCESS,
         dwCurrentState            = SERVICE_STATE.SERVICE_STOPPED,
         dwControlsAccepted        = 0,
         dwWin32ExitCode           = ERROR_SERVICE_SPECIFIC_ERROR,
         dwServiceSpecificExitCode = serviceSpecificExitCode,
         dwCheckPoint              = 0,
         dwWaitHint                = 5000,
     };
     bool serviceStatusRV = SetServiceStatus(serviceHandle, ref status);
     log.Debug("SetServiceStatus rv: {0}", serviceStatusRV);
 }
开发者ID:niemyjski,项目名称:ironfoundry,代码行数:15,代码来源:ServiceStatusUtil.cs

示例2: ControlService

 public static extern int ControlService( int hService,
     uint dwControl,
     ref SERVICE_STATUS lpServiceStatus);
开发者ID:dbose,项目名称:raagahacker,代码行数:3,代码来源:WinService.cs

示例3: SetServiceStatus

 public static extern bool SetServiceStatus(IntPtr hServiceStatus, ref SERVICE_STATUS lpServiceStatus);
开发者ID:fearthecowboy,项目名称:pinvoke,代码行数:1,代码来源:AdvApi32.cs

示例4: ControlService

 public static extern bool ControlService(SafeServiceHandle hService, ServiceControl dwControl, ref SERVICE_STATUS lpServiceStatus);
开发者ID:fearthecowboy,项目名称:pinvoke,代码行数:1,代码来源:AdvApi32.cs

示例5: StopService

 private static void StopService(IntPtr service)
 {
     SERVICE_STATUS status = new SERVICE_STATUS();
     ControlService(service, ServiceControl.Stop, status);
     var changedStatus = WaitForServiceStatus(service, ServiceState.StopPending, ServiceState.Stopped);
     if (!changedStatus)
         throw new ApplicationException("Unable to stop service");
 }
开发者ID:Sduniii,项目名称:SimpleBackuper,代码行数:8,代码来源:ServiceInstaller.cs

示例6: QueryServiceStatus

 private static extern int QueryServiceStatus(IntPtr hService, SERVICE_STATUS lpServiceStatus);
开发者ID:Sduniii,项目名称:SimpleBackuper,代码行数:1,代码来源:ServiceInstaller.cs

示例7: ControlService

 private static extern int ControlService(IntPtr hService, ServiceControl dwControl, SERVICE_STATUS lpServiceStatus);
开发者ID:Sduniii,项目名称:SimpleBackuper,代码行数:1,代码来源:ServiceInstaller.cs

示例8: StartService

 private static bool StartService(IntPtr service)
 {
     SERVICE_STATUS status = new SERVICE_STATUS();
     StartService(service, 0, 0);
     var changedStatus = WaitForServiceStatus(service, ServiceState.StartPending, ServiceState.Running);
     if (!changedStatus)
         return false;
     return true;
 }
开发者ID:kamilion,项目名称:WISP,代码行数:9,代码来源:ServiceInstaller.cs

示例9: QueryServiceStatus

 public static extern bool QueryServiceStatus(
     int Service, 
     ref SERVICE_STATUS ServiceStatus
     );
开发者ID:andyvand,项目名称:ProcessHacker,代码行数:4,代码来源:Functions.cs

示例10: ControlService

 public static extern bool ControlService(
     int Service,
     SERVICE_CONTROL Control, 
     ref SERVICE_STATUS ServiceStatus
     );
开发者ID:andyvand,项目名称:ProcessHacker,代码行数:5,代码来源:Functions.cs

示例11: ControlService

		private static extern bool ControlService (
			IntPtr hService,
			SERVICE_CONTROL_TYPE dwControl,
			ref SERVICE_STATUS lpServiceStatus);
开发者ID:nickchal,项目名称:pash,代码行数:4,代码来源:Win32ServiceController.cs

示例12: Stop

		public override void Stop ()
		{
			string serviceName = ServiceController.ServiceName;
			string machineName = ServiceController.MachineName;
			IntPtr scHandle = IntPtr.Zero;
			IntPtr svcHandle = IntPtr.Zero;

			try {
				scHandle = OpenServiceControlManager (machineName,
					SERVICE_MANAGER_RIGHTS.SC_MANAGER_CONNECT);

				svcHandle = OpenService (scHandle, serviceName, SERVICE_RIGHTS.SERVICE_STOP);
				if (svcHandle == IntPtr.Zero)
					throw CreateCannotOpenServiceException (serviceName,
						machineName);

				SERVICE_STATUS status = new SERVICE_STATUS ();
				if (!ControlService (svcHandle, SERVICE_CONTROL_TYPE.SERVICE_CONTROL_STOP, ref status))
					throw new InvalidOperationException (string.Format (
						CultureInfo.CurrentCulture, "Cannot stop {0} service"
						+ " on computer '{1}'.", serviceName, machineName),
						new Win32Exception ());
			} finally {
				if (svcHandle != IntPtr.Zero)
					CloseServiceHandle (svcHandle);
				if (scHandle != IntPtr.Zero)
					CloseServiceHandle (scHandle);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:29,代码来源:Win32ServiceController.cs

示例13: ExecuteCommand

		public override void ExecuteCommand (int command)
		{
			string serviceName = ServiceController.ServiceName;
			string machineName = ServiceController.MachineName;
			IntPtr scHandle = IntPtr.Zero;
			IntPtr svcHandle = IntPtr.Zero;

			try {
				scHandle = OpenServiceControlManager (machineName,
					SERVICE_MANAGER_RIGHTS.SC_MANAGER_CONNECT);

				// MSDN: the hService handle must have the SERVICE_USER_DEFINED_CONTROL
				// access right
				svcHandle = OpenService (scHandle, serviceName, SERVICE_RIGHTS.SERVICE_USER_DEFINED_CONTROL);
				if (svcHandle == IntPtr.Zero)
					throw CreateCannotOpenServiceException (serviceName,
						machineName);

				SERVICE_STATUS status = new SERVICE_STATUS ();
				if (!ControlService (svcHandle, (SERVICE_CONTROL_TYPE) command, ref status))
					throw new InvalidOperationException (string.Format (
						CultureInfo.CurrentCulture, "Cannot control {0} service"
						+ " on computer '{1}'.", serviceName, machineName),
						new Win32Exception ());
			} finally {
				if (svcHandle != IntPtr.Zero)
					CloseServiceHandle (svcHandle);
				if (scHandle != IntPtr.Zero)
					CloseServiceHandle (scHandle);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:31,代码来源:Win32ServiceController.cs

示例14: SetServiceStatus

 public static extern int SetServiceStatus( int hServiceStatus,
     ref SERVICE_STATUS lpServiceStatus);
开发者ID:dbose,项目名称:raagahacker,代码行数:2,代码来源:WinService.cs

示例15: QueryServiceStatus

 public static extern int QueryServiceStatus( int hService,
     ref SERVICE_STATUS lpServiceStatus);
开发者ID:dbose,项目名称:raagahacker,代码行数:2,代码来源:WinService.cs


注:本文中的SERVICE_STATUS类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。