In The Hand LtdIn The Hand
GetServices Method
NamespacesInTheHand.ServiceProcessServiceControllerGetServices()()()()
.NET Components for Mobility
Retrieves all the services on the local computer, except for the device driver services.
Declaration Syntax
C#Visual Basic
public static ServiceController[] GetServices()
Public Shared Function GetServices As ServiceController()
Return Value
An array of type ServiceController in which each element is associated with a service on the device.
Remarks
GetServices()()()() returns only the non-device driver services and the services that are not drivers from the local computer. To retrieve device driver services, call the GetDevices()()()() method. Together, the two methods provide access to all the services on a device.
Examples
The following example uses the ServiceController class to display the services that are running on the local device.
CopyVB.NET
Dim scServices() As ServiceController
scServices = ServiceController.GetServices()

' Display the list of services currently running on this device.
Debug.WriteLine("Services running on the local device:")

Dim scTemp As ServiceController
For Each scTemp In  scServices

    If scTemp.Status = ServiceControllerStatus.Running Then
    ' Write the service name and the display name
    ' for each running service.
    Debug.WriteLine()
    Debug.WriteLine("  Service :        {0}", scTemp.ServiceName)
    End If
Next scTemp
CopyC#
ServiceController[] scServices;
scServices = ServiceController.GetServices();
// Display the list of services currently running on this device.
Debug.WriteLine("Services running on the local device:");
foreach (ServiceController scTemp in scServices)
{
    if (scTemp.Status == ServiceControllerStatus.Running)
    {
        // Write the service name and the display name
        // for each running service.
        Console.WriteLine();
        Console.WriteLine("  Service :        {0}", scTemp.ServiceName);
    }
}
See Also

Assembly: InTheHand.ServiceProcess (Module: InTheHand.ServiceProcess) Version: 7.0.0.0