我需要获取有关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"]);
            }

但这并没有帮助我,只是没有这些信息。我如何获得此信息?

最佳答案

上面的代码在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

10-08 04:56