Initializes a new instance of the ServiceController class that is associated with an existing service on the local device.
- name (String)
- The short name that identifies the service to the system.
Under Windows CE all services are identified with a device style prefix and index e.g. APP0:
Toggles the state of the Obex listener service
CopyVB.NET
CopyC#
Dim sc As New ServiceController("OBX0:") If sc.Status = ServiceControllerStatus.Running Or sc.Status = ServiceControllerStatus.StartPending Then sc.Stop() Else sc.Start() End If
ServiceController sc = new ServiceController("OBX0:"); if(sc.Status==ServiceControllerStatus.Running | sc.Status==ServiceControllerStatus.StartPending) { sc.Stop(); } else { sc.Start(); }