mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 19:20:43 +01:00
CPU: support Windows 7
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -23,12 +23,15 @@ struct FFWmiRecord
|
||||
if(!ok) obj = nullptr;
|
||||
}
|
||||
FFWmiRecord(const FFWmiRecord&) = delete;
|
||||
FFWmiRecord(FFWmiRecord&& other) {
|
||||
obj = other.obj;
|
||||
other.obj = nullptr;
|
||||
}
|
||||
FFWmiRecord(FFWmiRecord&& other) { *this = (FFWmiRecord&&)other; }
|
||||
~FFWmiRecord() { if(obj) obj->Release(); }
|
||||
explicit operator bool() { return !!obj; }
|
||||
FFWmiRecord& operator =(FFWmiRecord&& other) {
|
||||
if(obj) obj->Release();
|
||||
obj = other.obj;
|
||||
other.obj = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool getString(const wchar_t* key, FFstrbuf* strbuf);
|
||||
bool getSigned(const wchar_t* key, int64_t* integer);
|
||||
@@ -43,13 +46,16 @@ struct FFWmiQuery
|
||||
FFWmiQuery(const wchar_t* queryStr, FFstrbuf* error = nullptr);
|
||||
explicit FFWmiQuery(IEnumWbemClassObject* pEnumerator): pEnumerator(pEnumerator) {}
|
||||
FFWmiQuery(const FFWmiQuery& other) = delete;
|
||||
FFWmiQuery(FFWmiQuery&& other) {
|
||||
pEnumerator = other.pEnumerator;
|
||||
other.pEnumerator = nullptr;
|
||||
}
|
||||
FFWmiQuery(FFWmiQuery&& other) { *this = (FFWmiQuery&&)other; }
|
||||
~FFWmiQuery() { if(pEnumerator) pEnumerator->Release(); }
|
||||
|
||||
explicit operator bool() { return !!pEnumerator; }
|
||||
FFWmiQuery& operator =(FFWmiQuery&& other) {
|
||||
if(pEnumerator) pEnumerator->Release();
|
||||
pEnumerator = other.pEnumerator;
|
||||
other.pEnumerator = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FFWmiRecord next() {
|
||||
FFWmiRecord result(pEnumerator);
|
||||
|
||||
Reference in New Issue
Block a user