我需要获得有关RAM模块的完整信息。我尝试使用WMI来获取它:
ManagementObjectSearcher searcher12 =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PhysicalMemory");
Console.WriteLine("------------- Win32_PhysicalMemory instance --------");
foreach (ManagementObject queryObj in searcher12.Get())
{
Console.WriteLine("BankLabel: {0} ; Capacity: {1} Gb; Speed: {2}; Manufacturer: {3}; Serial Number: {4}", queryObj["BankLabel"],
Math.Round(System.Convert.ToDouble(queryObj["Capacity"]) / 1024 / 1024 / 1024, 2),
queryObj["Speed"], queryObj["Manufacturer"], queryObj["Name"]);
}
但它没有帮助我,它根本没有这个信息。我怎样才能获得这些信息?
答案 0 :(得分:0)
上述代码适用于Windows 10.我将上述代码复制并粘贴到控制台应用程序中。
我必须添加对System.Management的引用。
当我运行它时,我得到以下输出:
------------- Win32_PhysicalMemory instance --------
BankLabel: BANK 0 ; Capacity: 4 Gb; Speed: 1333; Manufacturer: Hynix; Serial Number: Physical Memory
BankLabel: BANK 1 ; Capacity: 4 Gb; Speed: 1333; Manufacturer: Unknown; Serial Number: Physical Memory