public static RamInfo GetRamInfo() { List <RamInfo_Internal> dimms = new List <RamInfo_Internal>(); using (ManagementObjectSearcher win32Memory = new ManagementObjectSearcher("select * from Win32_PhysicalMemory")) { foreach (ManagementObject obj in win32Memory.Get()) { if (obj != null) { dimms.Add(new RamInfo_Internal(obj)); } } } HashSet <string> channels = new HashSet <string>(); long capacity = 0; int speed = 0; List <string> DimmLocations = new List <string>(); foreach (RamInfo_Internal dimm in dimms) { DimmLocations.Add(dimm.DeviceLocator); Match m = rxGetChannel.Match(dimm.DeviceLocator); if (m.Success) { channels.Add(m.Groups[1].Value); } capacity += dimm.Capacity; if (speed == 0) { speed = dimm.Speed; } } return(new RamInfo((float)NumberUtil.BytesToGiB(capacity), (ushort)channels.Count, (ushort)speed, string.Join(";", DimmLocations))); }