71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// File : gearmemory.cpp - GEAR Memory detection
|
|
// Copyright (c) Ubisoft Entertainment. All rights reserved.
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "gearmemory.h"
|
|
#include "gearhardware.h"
|
|
#include "systeminc.h"
|
|
|
|
#include <gear_detection/wmiinterface/wmiinterface.h>
|
|
|
|
namespace G4 {
|
|
|
|
namespace SystemDetection
|
|
{
|
|
GearMemory::GearMemory()
|
|
{
|
|
FillInformation();
|
|
}
|
|
|
|
void GearMemory::FillInformation()
|
|
{
|
|
WMIInterface wmi;
|
|
|
|
// The information found in WMI is not reliable
|
|
clockFrequencyHz = 0;
|
|
|
|
// We query the type of the first memory module
|
|
// It is very unlikely that several types of module are installed in one PC!
|
|
U32 wmiMemoryType = 0;
|
|
memoryType = Memory::MEMORYTYPE_UNKNOWN;
|
|
if (wmi.Query("Win32_PhysicalMemory", 0, "MemoryType", wmiMemoryType))
|
|
{
|
|
switch (wmiMemoryType)
|
|
{
|
|
case 17: // SDRAM
|
|
case 3: // Synchronous DRAM
|
|
memoryType = Memory::MEMORYTYPE_SDR;
|
|
break;
|
|
case 20: // DDR
|
|
memoryType = Memory::MEMORYTYPE_DDR;
|
|
break;
|
|
case 21: // DDR2
|
|
memoryType = Memory::MEMORYTYPE_DDR2;
|
|
break;
|
|
}
|
|
}
|
|
|
|
GearDetectionString totalPhysicalMemory;
|
|
totalSize = 0;
|
|
if (wmi.Query("Win32_ComputerSystem", 0, "TotalPhysicalMemory", totalPhysicalMemory))
|
|
{
|
|
totalPhysicalMemory.FromString(totalSize);
|
|
}
|
|
|
|
if (totalSize == 0)
|
|
{
|
|
// If WMI failed, we use the API instead
|
|
MEMORYSTATUSEX MemoryStatus;
|
|
MemoryStatus.dwLength = sizeof(MEMORYSTATUSEX);
|
|
if (GlobalMemoryStatusEx(&MemoryStatus))
|
|
{
|
|
totalSize = MemoryStatus.ullTotalPhys;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} // namespace G4()
|
|
|