Click or drag to resize

MemoryInfoProvider Constructor

Initializes a new instance of the MemoryInfoProvider class.

Namespace:  Xcalibur.WMI.Hardware.Memory
Assembly:  Xcalibur.WMI (in Xcalibur.WMI.dll) Version: 3.0.0.0 (3.0.1.0)
Syntax
public MemoryInfoProvider(
	ManagementScope ms
)

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
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    // Memory Info Provider
14    var provider = new MemoryInfoProvider(managementScope);
15
16    // Fetch data
17    provider.Refresh();
18
19    // Print Memory bank information
20    foreach (var info in provider.Results)
21    {
22        // Print system level information
23        Console.WriteLine("System Memory:");
24        Console.WriteLine("");
25        Console.WriteLine($"Total Slots: \t\t{info.TotalSlots}");
26        Console.WriteLine($"Total Memory: \t\t{info.TotalMemory}");
27        Console.WriteLine($"Max Memory Allowed: \t{info.MaximumMemory * 1024}");
28
29        // Spacer
30        Console.WriteLine("");
31        Console.WriteLine("");
32
33        // Print
34        Console.WriteLine("Slots:");
35        Console.WriteLine("");
36        foreach (var slot in info.Slots)
37        {
38            Console.WriteLine($"{slot.BankLabel}:  " +
39                              $"\t{slot.Manufacturer} - {slot.PartNumber} " +
40                              $"\t{slot.Capacity}" +
41                              $"\t{slot.Speed}");
42        }
43    }
44
45    // Read
46    Console.Read();
47}
48
49/* Results: 
50 * 
51 * System Memory:
52 * 
53 * Total Slots:            4
54 * Total Memory:           34359738368
55 * Max Memory Allowed:     68719476736
56 * 
57 * 
58 * Slots:
59 * 
60 * BANK 0:         G-Skill - F4-2800C15-8GVRB      8589934592      2800
61 * BANK 1:         G-Skill - F4-2800C15-8GVRB      8589934592      2800
62 * BANK 2:         G-Skill - F4-2800C15-8GVRB      8589934592      2800
63 * BANK 3:         G-Skill - F4-2800C15-8GVRB      8589934592      2800
64 * 
65 */
See Also