CPU: support Windows 7

This commit is contained in:
李通洲
2022-11-06 17:04:34 +08:00
parent 1ea44417d0
commit 85a554b60d
2 changed files with 27 additions and 12 deletions
+13 -4
View File
@@ -17,11 +17,21 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
FFWmiQuery query(L"SELECT Name, Manufacturer, NumberOfCores, NumberOfLogicalProcessors, ThreadCount, CurrentClockSpeed, MaxClockSpeed FROM Win32_Processor WHERE ProcessorType = 3");
FFWmiQuery query(L"SELECT Name, Manufacturer, NumberOfCores, NumberOfLogicalProcessors, NumberOfEnabledCore, CurrentClockSpeed, MaxClockSpeed FROM Win32_Processor WHERE ProcessorType = 3");
if(!query)
return;
if(FFWmiRecord record = query.next())
FFWmiRecord record = query.next();
if(!record)
{
//NumberOfEnabledCore is not supported on Windows 10-
query = FFWmiQuery(L"SELECT Name, Manufacturer, NumberOfCores, NumberOfLogicalProcessors, CurrentClockSpeed, MaxClockSpeed FROM Win32_Processor WHERE ProcessorType = 3");
if(!query)
return;
record = query.next();
}
if(record)
{
record.getString(L"Name", &cpu->name);
record.getString(L"Manufacturer", &cpu->vendor);
@@ -32,8 +42,7 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
cpu->coresPhysical = (uint16_t)value;
record.getUnsigned(L"NumberOfLogicalProcessors", &value);
cpu->coresLogical = (uint16_t)value;
record.getUnsigned(L"ThreadCount", &value);
cpu->coresOnline = (uint16_t)value;
cpu->coresOnline = record.getUnsigned(L"NumberOfEnabledCore", &value) ? (uint16_t)value : cpu->coresPhysical;
record.getUnsigned(L"CurrentClockSpeed", &value); //There's no MinClockSpeed in Win32_Processor
cpu->frequencyMin = (double)value / 1000.0;
record.getUnsigned(L"MaxClockSpeed", &value);