Click or drag to resize

ServiceInfoProvider Constructor

Initializes a new instance of the ServiceInfoProvider class.

Namespace:  Xcalibur.WMI.Services
Assembly:  Xcalibur.WMI (in Xcalibur.WMI.dll) Version: 3.0.0.0 (3.0.1.0)
Syntax
public ServiceInfoProvider(
	ManagementScope ms,
	string name = "",
	ServiceGrouping grouping = ServiceGrouping.All
)

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
name (Optional)
Type: SystemString
The service name.
grouping (Optional)
Type: Xcalibur.Models.EnumsServiceGrouping
The service grouping.
Examples
C#
 1// Main
 2private static void Main()
 3{
 4    // Make a connection to the local machine
 5    const string computer = ".";
 6    var managementScope = new ManagementScope($@"\\{computer}\root\cimv2", new ConnectionOptions
 7    {
 8        Impersonation = ImpersonationLevel.Impersonate,
 9        Authentication = AuthenticationLevel.Connect
10    });
11    managementScope.Connect();
12
13    // Service information
14    var provider = new ServiceInfoProvider(managementScope);
15
16    // Fetch data
17    provider.Refresh();
18
19    // Print first 5 services
20    foreach (var info in provider.Results.Take(5))
21    {
22        Console.WriteLine($"{info.Name}, {info.State}, {info.ProcessId}");
23    }
24
25    // Read
26    Console.Read();
27}
28
29/* Results: 
30 * 
31 * Adobe LM Service, Stopped, 0
32 * AdobeARMservice, Running, 3376
33 * AdobeFlashPlayerUpdateSvc, Stopped, 0
34 * AdobeUpdateService, Running, 4048
35 * AGSService, Running, 3872
36 * 
37 */
See Also