122 references to Interop
System.ServiceProcess.ServiceController (122)
_generated\0\LibraryImports.g.cs (7)
35
internal static unsafe partial bool ControlService(global::Microsoft.Win32.SafeHandles.SafeServiceHandle serviceHandle, int control, global::
Interop
.Advapi32.SERVICE_STATUS* pStatus)
68
static extern unsafe int __PInvoke(nint __serviceHandle_native, int __control_native, global::
Interop
.Advapi32.SERVICE_STATUS* __pStatus_native);
380
internal static unsafe partial bool QueryServiceStatus(global::Microsoft.Win32.SafeHandles.SafeServiceHandle serviceHandle, global::
Interop
.Advapi32.SERVICE_STATUS* pStatus)
413
static extern unsafe int __PInvoke(nint __serviceHandle_native, global::
Interop
.Advapi32.SERVICE_STATUS* __pStatus_native);
466
public static unsafe partial bool SetServiceStatus(nint serviceStatusHandle, global::
Interop
.Advapi32.SERVICE_STATUS* status)
483
static extern unsafe int __PInvoke(nint __serviceStatusHandle_native, global::
Interop
.Advapi32.SERVICE_STATUS* __status_native);
493
public static partial nint RegisterServiceCtrlHandlerEx(string serviceName, global::
Interop
.Advapi32.ServiceControlCallbackEx callback, nint userData)
Microsoft\Win32\SafeHandles\SafeServiceHandle.cs (1)
30
return
Interop
.Advapi32.CloseServiceHandle(handle);
System\ServiceProcess\PowerBroadcastStatus.cs (9)
8
BatteryLow =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMBATTERYLOW,
9
OemEvent =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMOEMEVENT,
10
PowerStatusChange =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMPOWERSTATUSCHANGE,
11
QuerySuspend =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMQUERYSUSPEND,
12
QuerySuspendFailed =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMQUERYSUSPENDFAILED,
13
ResumeAutomatic =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMRESUMEAUTOMATIC,
14
ResumeCritical =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMRESUMECRITICAL,
15
ResumeSuspend =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMRESUMESUSPEND,
16
Suspend =
Interop
.Advapi32.PowerBroadcastStatus.PBT_APMSUSPEND,
System\ServiceProcess\ServiceBase.cs (1)
12
using static
Interop
.Advapi32;
System\ServiceProcess\ServiceController.cs (76)
79
private ServiceController(string machineName,
Interop
.Advapi32.ENUM_SERVICE_STATUS status)
98
private ServiceController(string machineName,
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS status)
120
return (_commandsAccepted &
Interop
.Advapi32.AcceptOptions.ACCEPT_PAUSE_CONTINUE) != 0;
132
return (_commandsAccepted &
Interop
.Advapi32.AcceptOptions.ACCEPT_SHUTDOWN) != 0;
144
return (_commandsAccepted &
Interop
.Advapi32.AcceptOptions.ACCEPT_STOP) != 0;
186
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_ENUMERATE_DEPENDENTS);
190
bool result =
Interop
.Advapi32.EnumDependentServices(serviceHandle,
Interop
.Advapi32.ServiceState.SERVICE_STATE_ALL, IntPtr.Zero, 0,
199
if (lastError !=
Interop
.Errors.ERROR_MORE_DATA)
208
result =
Interop
.Advapi32.EnumDependentServices(serviceHandle,
Interop
.Advapi32.ServiceState.SERVICE_STATE_ALL, enumBuffer, bytesNeeded,
218
Interop
.Advapi32.ENUM_SERVICE_STATUS status = new
Interop
.Advapi32.ENUM_SERVICE_STATUS();
219
IntPtr structPtr = (IntPtr)(pEnumBuffer + ((nint)i * Marshal.SizeOf<
Interop
.Advapi32.ENUM_SERVICE_STATUS>()));
304
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_QUERY_CONFIG);
305
bool success =
Interop
.Advapi32.QueryServiceConfig(serviceHandle, IntPtr.Zero, 0, out int bytesNeeded);
313
if (lastError !=
Interop
.Errors.ERROR_INSUFFICIENT_BUFFER)
320
success =
Interop
.Advapi32.QueryServiceConfig(serviceHandle, bufPtr, bytesNeeded, out bytesNeeded);
324
Interop
.Advapi32.QUERY_SERVICE_CONFIG config = new
Interop
.Advapi32.QUERY_SERVICE_CONFIG();
346
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS[] loadGroup = GetServicesInGroup(_machineName, dependencyNameStr.Substring(1));
347
foreach (
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS groupMember in loadGroup)
388
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_QUERY_CONFIG);
389
bool success =
Interop
.Advapi32.QueryServiceConfig(serviceHandle, IntPtr.Zero, 0, out int bytesNeeded);
392
if (lastError !=
Interop
.Errors.ERROR_INSUFFICIENT_BUFFER)
399
success =
Interop
.Advapi32.QueryServiceConfig(serviceHandle, bufPtr, bytesNeeded, out bytesNeeded);
403
Interop
.Advapi32.QUERY_SERVICE_CONFIG config = new
Interop
.Advapi32.QUERY_SERVICE_CONFIG();
422
return GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_ALL_ACCESS);
498
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_QUERY_STATUS);
499
Interop
.Advapi32.SERVICE_STATUS svcStatus = default;
500
bool success =
Interop
.Advapi32.QueryServiceStatus(serviceHandle, &svcStatus);
542
throw new InvalidOperationException(SR.Format(SR.NoService, userGivenName, _machineName), new Win32Exception(
Interop
.Errors.ERROR_SERVICE_DOES_NOT_EXIST));
556
throw new InvalidOperationException(SR.Format(SR.NoService, _name, _machineName), new Win32Exception(
Interop
.Errors.ERROR_SERVICE_DOES_NOT_EXIST));
577
if (
Interop
.Advapi32.GetServiceKeyName(SCMHandle, serviceDisplayName, c, ref bufLen))
582
if (lastError ==
Interop
.Errors.ERROR_SERVICE_DOES_NOT_EXIST)
587
if (lastError !=
Interop
.Errors.ERROR_INSUFFICIENT_BUFFER)
608
if (
Interop
.Advapi32.GetServiceDisplayName(scmHandle, serviceName, c, ref bufLen))
613
if (lastError ==
Interop
.Errors.ERROR_SERVICE_DOES_NOT_EXIST)
617
else if (lastError !=
Interop
.Errors.ERROR_INSUFFICIENT_BUFFER)
633
Interop
.Advapi32.OpenSCManager(null, null, serviceControlManagerAccess) :
634
Interop
.Advapi32.OpenSCManager(machineName, null, serviceControlManagerAccess));
654
_serviceManagerHandle ??= GetDataBaseHandleWithAccess(_machineName,
Interop
.Advapi32.ServiceControllerOptions.SC_MANAGER_CONNECT);
673
return GetServicesOfType(machineName,
Interop
.Advapi32.ServiceTypeOptions.SERVICE_DRIVER);
686
Marshal.InitHandle(serviceHandle,
Interop
.Advapi32.OpenService(_serviceManagerHandle, ServiceName, desiredAccess));
713
return GetServicesOfType(machineName,
Interop
.Advapi32.ServiceTypeOptions.SERVICE_WIN32);
722
private static
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS[] GetServicesInGroup(string machineName, string group)
724
return GetServices(machineName,
Interop
.Advapi32.ServiceTypeOptions.SERVICE_WIN32, group, status => status);
742
private static unsafe T[] GetServices<T>(string machineName, int serviceType, string? group, Func<
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS, T> selector)
748
using SafeServiceHandle databaseHandle = GetDataBaseHandleWithAccess(machineName,
Interop
.Advapi32.ServiceControllerOptions.SC_MANAGER_ENUMERATE_SERVICE);
749
Interop
.Advapi32.EnumServicesStatusEx(
751
Interop
.Advapi32.ServiceControllerOptions.SC_ENUM_PROCESS_INFO,
753
Interop
.Advapi32.StatusOptions.STATUS_ALL,
767
Interop
.Advapi32.EnumServicesStatusEx(
769
Interop
.Advapi32.ServiceControllerOptions.SC_ENUM_PROCESS_INFO,
771
Interop
.Advapi32.StatusOptions.STATUS_ALL,
786
IntPtr structPtr = (IntPtr)(pMemory + ((nint)i * Marshal.SizeOf<
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS>()));
787
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS status = new
Interop
.Advapi32.ENUM_SERVICE_STATUS_PROCESS();
805
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_PAUSE_CONTINUE);
806
Interop
.Advapi32.SERVICE_STATUS status = default;
807
bool result =
Interop
.Advapi32.ControlService(serviceHandle,
Interop
.Advapi32.ControlOptions.CONTROL_PAUSE, &status);
821
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_PAUSE_CONTINUE);
822
Interop
.Advapi32.SERVICE_STATUS status = default;
823
bool result =
Interop
.Advapi32.ControlService(serviceHandle,
Interop
.Advapi32.ControlOptions.CONTROL_CONTINUE, &status);
837
using var serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_USER_DEFINED_CONTROL);
838
Interop
.Advapi32.SERVICE_STATUS status = default;
839
bool result =
Interop
.Advapi32.ControlService(serviceHandle, command, &status);
873
using SafeServiceHandle serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_START);
897
bool result =
Interop
.Advapi32.StartService(serviceHandle, args.Length, argPtrsHandle.AddrOfPinnedObject());
940
using SafeServiceHandle serviceHandle = GetServiceHandle(
Interop
.Advapi32.ServiceOptions.SERVICE_STOP);
957
Interop
.Advapi32.SERVICE_STATUS status = default;
958
bool result =
Interop
.Advapi32.ControlService(serviceHandle,
Interop
.Advapi32.ControlOptions.CONTROL_STOP, &status);
System\ServiceProcess\ServiceControllerStatus.cs (7)
8
ContinuePending =
Interop
.Advapi32.ServiceControlStatus.STATE_CONTINUE_PENDING,
9
Paused =
Interop
.Advapi32.ServiceControlStatus.STATE_PAUSED,
10
PausePending =
Interop
.Advapi32.ServiceControlStatus.STATE_PAUSE_PENDING,
11
Running =
Interop
.Advapi32.ServiceControlStatus.STATE_RUNNING,
12
StartPending =
Interop
.Advapi32.ServiceControlStatus.STATE_START_PENDING,
13
Stopped =
Interop
.Advapi32.ServiceControlStatus.STATE_STOPPED,
14
StopPending =
Interop
.Advapi32.ServiceControlStatus.STATE_STOP_PENDING
System\ServiceProcess\ServiceStartMode.cs (5)
8
Manual =
Interop
.Advapi32.ServiceStartModes.START_TYPE_DEMAND,
9
Automatic =
Interop
.Advapi32.ServiceStartModes.START_TYPE_AUTO,
10
Disabled =
Interop
.Advapi32.ServiceStartModes.START_TYPE_DISABLED,
11
Boot =
Interop
.Advapi32.ServiceStartModes.START_TYPE_BOOT,
12
System =
Interop
.Advapi32.ServiceStartModes.START_TYPE_SYSTEM
System\ServiceProcess\ServiceType.cs (7)
10
Adapter =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_ADAPTER,
11
FileSystemDriver =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_FILE_SYSTEM_DRIVER,
12
InteractiveProcess =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_INTERACTIVE_PROCESS,
13
KernelDriver =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_KERNEL_DRIVER,
14
RecognizerDriver =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_RECOGNIZER_DRIVER,
15
Win32OwnProcess =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_WIN32_OWN_PROCESS,
16
Win32ShareProcess =
Interop
.Advapi32.ServiceTypeOptions.SERVICE_WIN32_SHARE_PROCESS
System\ServiceProcess\SessionChangeReason.cs (9)
14
ConsoleConnect =
Interop
.Advapi32.SessionStateChange.WTS_CONSOLE_CONNECT,
19
ConsoleDisconnect =
Interop
.Advapi32.SessionStateChange.WTS_CONSOLE_DISCONNECT,
24
RemoteConnect =
Interop
.Advapi32.SessionStateChange.WTS_REMOTE_CONNECT,
29
RemoteDisconnect =
Interop
.Advapi32.SessionStateChange.WTS_REMOTE_DISCONNECT,
34
SessionLogon =
Interop
.Advapi32.SessionStateChange.WTS_SESSION_LOGON,
39
SessionLogoff =
Interop
.Advapi32.SessionStateChange.WTS_SESSION_LOGOFF,
44
SessionLock =
Interop
.Advapi32.SessionStateChange.WTS_SESSION_LOCK,
49
SessionUnlock =
Interop
.Advapi32.SessionStateChange.WTS_SESSION_UNLOCK,
54
SessionRemoteControl =
Interop
.Advapi32.SessionStateChange.WTS_SESSION_REMOTE_CONTROL