如何确定计算机上安装的物理 RAM? (windows)

How I can determine physical RAM installed on computer? (windows)

如何在 Windows 中使用 C++ 将物理内存安装到我的计算机上? 我的意思不仅是可以 GlobalMemoryStatusEx() 的容量参数,还有已用内存插槽的数量、内存类型(如 DDR1/DDR2/DDR3)、插槽类型(DIMM/SO-DIMM)和内存总线的时钟速率. 我需要使用 SMBIOS 吗?或者有其他方式获取此信息吗?

在我的机器上,您请求的大部分信息都可以通过 WMI 获得。看看 Win32_PhysicalMemory 和相关的 类.

比如wmic memorychip在我机器上的输出是:

C:\>wmic memorychip
Attributes  BankLabel  Capacity     Caption          ConfiguredClockSpeed  ConfiguredVoltage  CreationClassName     DataWidth  Description      DeviceLocator   FormFactor  HotSwappable  InstallDate  InterleaveDataDepth  InterleavePosition  Manufacturer  MaxVoltage  MemoryType  MinVoltage  Model  Name             OtherIdentifyingInfo  PartNumber        PositionInRow  PoweredOn  Removable  Replaceable  SerialNumber  SKU  SMBIOSMemoryType  Speed  Status  Tag                TotalWidth  TypeDetail  Version
2           BANK 0     17179869184  Physical Memory  2133                  1200               Win32_PhysicalMemory  64         Physical Memory  ChannelA-DIMM0  12                                                                              Samsung       0           0           0                  Physical Memory                        M471A2K43BB1-CPB                                                    15741117           26                2133           Physical Memory 0  64          128
2           BANK 2     17179869184  Physical Memory  2133                  1200               Win32_PhysicalMemory  64         Physical Memory  ChannelB-DIMM0  12                                                                              Samsung       0           0           0                  Physical Memory                        M471A2K43BB1-CPB                                                    21251413           26                2133           Physical Memory 2  64          128

如上面 link 中所述,FormFactor 12 是 SODIMM。

明显缺少电压(您没有要求,但通常很感兴趣)和 MemoryType,其文档在 MSDN 上已过时,而 DMTF 最近的 SMBIOS 文档包括DDR4 枚举中的值。等等

因此,您可能不得不或多或少地手动查看 SMBIOS 表。参见:How to get memory information (RAM type, e.g. DDR,DDR2,DDR3?) with WMI/C++