.net c# 通过ManagementClass初始化Win32_Processor信息,遍历获取物理内存详细数值信息
源码:
/// <summary>
/// 其它硬件信息
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public string PhicnalInfo()
{
StringBuilder str = new StringBuilder();
string name = "Win32_PhysicalMemory";
ManagementClass osClass = new ManagementClass(name);
foreach (ManagementObject obj in osClass.GetInstances())
{
PropertyDataCollection pdc = obj.Properties;
foreach (PropertyData pd in pdc)
{
str.AppendLine(string.Format("{0}: {1}", pd.Name, pd.Value));
}
}
return str.ToString();
}
运行结果:
Attributes: 2
BankLabel: BANK 0
Capacity: 8589934592
Caption: 物理内存
ConfiguredClockSpeed: 1600
ConfiguredVoltage:
CreationClassName: Win32_PhysicalMemory
DataWidth: 64
Description: 物理内存
DeviceLocator: ChannelA-DIMM0
FormFactor: 8
HotSwappable:
InstallDate:
InterleaveDataDepth:
InterleavePosition:
Manufacturer: Kingston
MaxVoltage:
MemoryType: 24
MinVoltage:
Model:
Name: 物理内存
OtherIdentifyingInfo:
PartNumber: 99P5471-033.A00LF
PositionInRow:
PoweredOn:
Removable:
Replaceable:
SerialNumber: ED0482C2
SKU:
SMBIOSMemoryType: 24
Speed: 1600
Status:
Tag: Physical Memory 0
TotalWidth: 64
TypeDetail: 128
Version:
Attributes: 2
BankLabel: BANK 1
Capacity: 8589934592
Caption: 物理内存
ConfiguredClockSpeed: 1600
ConfiguredVoltage:
CreationClassName: Win32_PhysicalMemory
DataWidth: 64
Description: 物理内存
DeviceLocator: ChannelA-DIMM1
FormFactor: 8
HotSwappable:
InstallDate:
InterleaveDataDepth:
InterleavePosition:
Manufacturer: Kingston
MaxVoltage:
MemoryType: 24
MinVoltage:
Model:
Name: 物理内存
OtherIdentifyingInfo:
PartNumber: 99P5471-033.A00LF
PositionInRow:
PoweredOn:
Removable:
Replaceable:
SerialNumber: EB04E8C1
SKU:
SMBIOSMemoryType: 24
Speed: 1600
Status:
Tag: Physical Memory 1
TotalWidth: 64
TypeDetail: 128
Version:
Attributes: 2
BankLabel: BANK 2
Capacity: 8589934592
Caption: 物理内存
ConfiguredClockSpeed: 1600
ConfiguredVoltage:
CreationClassName: Win32_PhysicalMemory
DataWidth: 64
Description: 物理内存
DeviceLocator: ChannelB-DIMM0
FormFactor: 8
HotSwappable:
InstallDate:
InterleaveDataDepth:
InterleavePosition:
Manufacturer: Kingston
MaxVoltage:
MemoryType: 24
MinVoltage:
Model:
Name: 物理内存
OtherIdentifyingInfo:
PartNumber: 99P5471-033.A00LF
PositionInRow:
PoweredOn:
Removable:
Replaceable:
SerialNumber: E804EDC1
SKU:
SMBIOSMemoryType: 24
Speed: 1600
Status:
Tag: Physical Memory 2
TotalWidth: 64
TypeDetail: 128
Version:
Attributes: 2
BankLabel: BANK 3
Capacity: 8589934592
Caption: 物理内存
ConfiguredClockSpeed: 1600
ConfiguredVoltage:
CreationClassName: Win32_PhysicalMemory
DataWidth: 64
Description: 物理内存
DeviceLocator: ChannelB-DIMM1
FormFactor: 8
HotSwappable:
InstallDate:
InterleaveDataDepth:
InterleavePosition:
Manufacturer: Kingston
MaxVoltage:
MemoryType: 24
MinVoltage:
Model:
Name: 物理内存
OtherIdentifyingInfo:
PartNumber: 99P5471-033.A00LF
PositionInRow:
PoweredOn:
Removable:
Replaceable:
SerialNumber: ED044AC1
SKU:
SMBIOSMemoryType: 24
Speed: 1600
Status:
Tag: Physical Memory 3
TotalWidth: 64
TypeDetail: 128
Version:
图片展示效果: