Click or drag to resize

NetworkAdapterConfigurationInfoProvider Constructor

Initializes a new instance of the NetworkAdapterConfigurationInfoProvider class.

Namespace:  Xcalibur.WMI.Hardware.Network
Assembly:  Xcalibur.WMI (in Xcalibur.WMI.dll) Version: 3.0.0.0 (3.0.1.0)
Syntax
public NetworkAdapterConfigurationInfoProvider(
	ManagementScope ms,
	int id = -1
)

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
id (Optional)
Type: SystemInt32
The Interface Index Id.
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    // Network Adapter Configuration Info Provider
14    var provider = new NetworkAdapterConfigurationInfoProvider(managementScope);
15
16    // Fetch data
17    provider.Refresh();
18
19    // Print
20    foreach (var info in provider.Results.Where(x => x.IpAddress != null))
21    {
22        Console.WriteLine($"{info.Description}");
23        Console.WriteLine($"{info.IpAddress[0]}");
24        Console.WriteLine($"{info.IpSubnet[0]}");
25        Console.WriteLine($"{info.DefaultIpGateway[0]}");
26        Console.WriteLine($"{info.MacAddress}");
27        Console.WriteLine("");
28    } 
29
30    // Read
31    Console.Read();
32}
33
34/* Results: 
35 * 
36 * Intel(R) Ethernet Connection (2) I219-V
37 * 192.168.37.150
38 * 255.255.255.0
39 * 192.168.37.1
40 * 14:DD:A9:EE:B0:1D
41 * 
42 */
See Also