如何使用 WMI/C++ 获取内存信息(RAM 类型,例如 DDR、DDR2、DDR3?)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14227171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 18:08:34  来源:igfitidea点击:

How to get memory information (RAM type, e.g. DDR,DDR2,DDR3?) with WMI/C++

c++wmi

提问by user1959883

I have DDR2 RAM on my windows XP SP 2 Machine, but on WMI explorer (win32_physicalMemory) I am getting Memory Type = 0(Unknown) instead of 21(the code for DDR2). NameSpace is CIMV2. Can you please tell me how to get DDR2 Memory Type From WMI?

我的 Windows XP SP 2 机器上有 DDR2 RAM,但在 WMI 资源管理器 (win32_physicalMemory) 上,我得到内存类型 = 0(未知)而不是 21(DDR2 的代码)。命名空间是 CIMV2。你能告诉我如何从 WMI 获取 DDR2 内存类型吗?

回答by RRUZ

One of the most reliable ways to get such info is reading the SMBIOSTables, you must look for the Memory Device (Type 17) Structure(this structure describes a single memory device installed on the system), and the Memory TypeField.

获取此类信息的最可靠方法之一是读取SMBIOS表,您必须查找Memory Device (Type 17) Structure(此结构描述系统上安装的单个内存设备)和Memory Type字段。

These are the possible values of this field.

这些是该字段的可能值。

01h Other
02h Unknown
03h DRAM
04h EDRAM
05h VRAM
06h SRAM
07h RAM
08h ROM
09h FLASH
0Ah EEPROM
0Bh FEPROM   
0Ch EPROM
0Dh CDRAM
0Eh 3DRAM
0Fh SDRAM
10h SGRAM
11h RDRAM
12h DDR
13h DDR2
14h DDR2 FB-DIMM
15h-17h Reserved
18h DDR3
19h FBD2
1Ah DDR4
1Bh LPDDR
1Ch LPDDR2
1Dh LPDDR3
1Eh LPDDR4

In order to access the SMBIOS from a C++ application you can use the MSSmBios_RawSMBiosTablesWMI Class or the EnumSystemFirmwareTablesand GetSystemFirmwareTablefunctions.

为了从 C++ 应用程序访问 SMBIOS,您可以使用MSSmBios_RawSMBiosTablesWMI 类或EnumSystemFirmwareTablesGetSystemFirmwareTable函数。

Additionally check these articles to see how parse the infor of the SMBIOS tables.

另外检查这些文章以了解如何解析 SMBIOS 表的信息。