通过WMI接口中的Win32_MemoryDevice  MemoryType不能完全识别,有的机器返回0,需要实现类似CPU-Z直接识别内存种类和内存条数量的功能。

解决方案 »

  1.   

    http://delphi.ktop.com.tw/board.php?tid=70304樓主參考一下!不知道對你有沒有幫助
      

  2.   

    Win32_MemoryDevice下面没有看到有你说的MemoryType这项啊.
    class Win32_MemoryDevice : Win32_SMBIOSMemory
    {
      uint16 Access;
      uint8 AdditionalErrorData[];
      uint16 Availability;
      uint64 BlockSize;
      string Caption;
      uint32 ConfigManagerErrorCode;
      boolean ConfigManagerUserConfig;
      boolean CorrectableError;
      string CreationClassName;
      string Description;
      string DeviceID;
      uint64 EndingAddress;
      uint16 ErrorAccess;
      uint64 ErrorAddress;
      boolean ErrorCleared;
      uint8 ErrorData[];
      uint16 ErrorDataOrder;
      string ErrorDescription;
      uint16 ErrorGranularity;
      uint16 ErrorInfo;
      string ErrorMethodology;
      uint64 ErrorResolution;
      datetime ErrorTime;
      uint32 ErrorTransferSize;
      datetime InstallDate;
      uint32 LastErrorCode;
      string Name;
      uint64 NumberOfBlocks;
      string OtherErrorDescription;
      string PNPDeviceID;
      uint16 PowerManagementCapabilities[];
      boolean PowerManagementSupported;
      string Purpose;
      uint64 StartingAddress;
      string Status;
      uint16 StatusInfo;
      string SystemCreationClassName;
      boolean SystemLevelAddress;
      string SystemName;
    };
    你是在读取哪个值的时候有问题,给点代码好分析.
      

  3.   

    对不起,前面输错了,是调用WMI接口读取Win32_PhysicalMemory的MemoryType值,在不同的机器上会得到不同的值,但在很多机器上返回0,在DDR内存的机器上返回17,表示SDRAM,实际应该返回20,表示DDR。我是希望直接通过程序识别内存条的类型是什么,就像cpu-z等软件一样。附件1:class Win32_PhysicalMemory : CIM_PhysicalMemory
    {
      string   BankLabel;
      uint64   Capacity;
      string   Caption;
      string   CreationClassName;
      uint16   DataWidth;
      string   Description;
      string   DeviceLocator;
      uint16   FormFactor;
      boolean  HotSwappable;
      datetime InstallDate;
      uint16   InterleaveDataDepth;
      uint32   InterleavePosition;
      string   Manufacturer;
      uint16   MemoryType;
      string   Model;
      string   Name;
      string   OtherIdentifyingInfo;
      string   PartNumber;
      uint32   PositionInRow;
      boolean  PoweredOn;
      boolean  Removable;
      boolean  Replaceable;
      string   SerialNumber;
      string   SKU;
      uint32   Speed;
      string   Status;
      string   Tag;
      uint16   TotalWidth;
      uint16   TypeDetail;
      string   Version;
    };附件2:
    MemoryType
    Data type: uint16
    Access type: Read-only
    Type of physical memory. This property is inherited from CIM_PhysicalMemory.
    Value Meaning
    0 Unknown
    1 Other
    2 DRAM
    3 Synchronous DRAM
    4 Cache DRAM
    5 EDO
    6 EDRAM
    7 VRAM
    8 SRAM
    9 RAM
    10 ROM
    11 Flash
    12 EEPROM
    13 FEPROM
    14 EPROM
    15 CDRAM
    16 3DRAM
    17 SDRAM
    18 SGRAM
    19 RDRAM
    20 DDR
    21 DDR-2
      

  4.   

    示例代码:function GetWMIProperty(WMIType, WMIProperty: string): string;
    var
      Wmi, Objs, Obj: OleVariant;
      Enum: IEnumVariant;
      C: Cardinal;
    begin
      Wmi:= CreateOleObject('WbemScripting.SWbemLocator');
      Objs := Wmi.ConnectServer('.','root\cimv2').ExecQuery('Select * from Win32_' + WMIType);
      Enum := IEnumVariant(IUnknown(Objs._NewEnum));
      Enum.Reset;
      Enum.Next(1, Obj, C);
      Obj := Obj.Properties_.Item(WMIProperty, 0).Value;
      Result := Obj;
    end;ShowMessage(GetWMIProperty('PhysicalMemory', 'MemoryType'));
      

  5.   

    CPU-Z有个SDK公开出售,超级兔子用的就是那个SDK,原理是通过驱动读SPD。
      

  6.   

    WMI的深度有限,想要确保取到正确的信息,就要从核心驱动层去读SPD数据.
      

  7.   

    wmi读取的这个实际上应该是dmi中的。之所以会出现偏差,很可能是bios没有将正确的写入dmi导致的。如果要准确的话,就要研究北桥的spec,很麻烦的。
      

  8.   

    WMI里的信息确实没有使用价值