本文整理汇总了C#中SERVICE_STATUS类的典型用法代码示例。如果您正苦于以下问题:C# SERVICE_STATUS类的具体用法?C# SERVICE_STATUS怎么用?C# SERVICE_STATUS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SERVICE_STATUS类属于命名空间,在下文中一共展示了SERVICE_STATUS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: PauseService
private void PauseService(IntPtr service, bool wait = true)
{
if (this.GetServiceStatus(service) != ServiceState.Running)
throw new ServiceOperationException(this._serviceName, "Pause", "Cannot pause a service which isn't already running");
var status = new SERVICE_STATUS();
ControlService(service, ServiceControl.Pause, status);
if (wait)
{
var changedStatus = this.WaitForServiceStatus(service, ServiceState.PausePending, ServiceState.Paused);
if (!changedStatus)
throw new ServiceOperationException(this._serviceName, "Pause", "Unable to pause service");
}
}
开发者ID:Ascent691,项目名称:PeanutButter,代码行数:13,代码来源:WindowsServiceUtil.cs
示例17: StopService
private void StopService(IntPtr service, bool wait = true)
{
if (this.GetServiceStatus(service) != ServiceState.Running)
return;
var process = Process.GetProcessById(this.ServicePID);
SERVICE_STATUS status = new SERVICE_STATUS();
ControlService(service, ServiceControl.Stop, status);
const string op = "Stop";
if (wait)
{
var changedStatus = this.WaitForServiceStatus(service, ServiceState.StopPending, ServiceState.Stopped);
if (!changedStatus)
throw new ServiceOperationException(this._serviceName, op, "Unable to stop service");
var waitLevel = 0;
try
{
if (!process.HasExited)
{
waitLevel++;
if (!process.WaitForExit((int)this._serviceStopTimeoutMS))
{
waitLevel++;
process.Kill();
}
}
}
catch (Exception ex)
{
switch (waitLevel)
{
case 0:
throw new ServiceOperationException(this._serviceName, op,
GenerateStopExceptionMessageWith("but threw errors when interrogating process state", ex));
case 1:
throw new ServiceOperationException(this._serviceName, op,
GenerateStopExceptionMessageWith("and we got an error whilst waiting 10 seconds for graceful exit", ex));
case 2:
throw new ServiceOperationException(this._serviceName, op,
GenerateStopExceptionMessageWith("and we got an error after trying to kill it when it didn't gracefully exit within 10 seconds", ex));
}
}
}
}
开发者ID:Ascent691,项目名称:PeanutButter,代码行数:44,代码来源:WindowsServiceUtil.cs
示例18: SetServiceStatus
public static extern unsafe bool SetServiceStatus(IntPtr serviceStatusHandle, SERVICE_STATUS* status);
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:1,代码来源:NativeMethods.cs
示例19: StopService
private static bool StopService(IntPtr service)
{
SERVICE_STATUS status = new SERVICE_STATUS();
ControlService(service, ServiceControl.Stop, status);
var changedStatus = WaitForServiceStatus(service, ServiceState.StopPending, ServiceState.Stopped);
if (!changedStatus)
return false;
return true;
}
开发者ID:kamilion,项目名称:WISP,代码行数:9,代码来源:ServiceInstaller.cs
示例20: StartService
/// <summary>
/// Stars the provided windows service
/// </summary>
/// <param name="hService">The handle to the windows service</param>
private static void StartService(IntPtr hService)
{
SERVICE_STATUS status = new SERVICE_STATUS();
StartService(hService, 0, 0);
WaitForServiceStatus(hService, ServiceState.Starting, ServiceState.Run);
}
开发者ID:sirmmo,项目名称:SignageStudioAgent,代码行数:10,代码来源:ServiceTools.cs
注:本文中的SERVICE_STATUS类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论