Can get CPU brand.

This commit is contained in:
NissimHadar 2018-12-29 17:24:44 -08:00
parent 246c4dab94
commit 63ea300921
2 changed files with 37 additions and 0 deletions

View file

@ -21,3 +21,37 @@ QString PlatformInfoScriptingInterface::getOperatingSystemType() {
return "UNKNOWN";
#endif
}
QString PlatformInfoScriptingInterface::getCPUBrand() {
int CPUInfo[4] = { -1 };
unsigned nExIds, i = 0;
char CPUBrandString[0x40];
// Get the information associated with each extended ID.
__cpuid(CPUInfo, 0x80000000);
nExIds = CPUInfo[0];
for (i = 0x80000000; i <= nExIds; ++i) {
__cpuid(CPUInfo, i);
// Interpret CPU brand string
if (i == 0x80000002) {
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
} else if (i == 0x80000003) {
memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
} else if (i == 0x80000004) {
memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
}
}
return CPUBrandString;
//////string includes manufacturer, model and clockspeed
////cout << "CPU Type: " << CPUBrandString << endl;
////SYSTEM_INFO sysInfo;
////GetSystemInfo(&sysInfo);
////cout << "Number of Cores: " << sysInfo.dwNumberOfProcessors << endl;
////MEMORYSTATUSEX statex;
////statex.dwLength = sizeof (statex);
////GlobalMemoryStatusEx(&statex);
////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl;
}

View file

@ -28,7 +28,10 @@ public slots:
/**jsdoc
* Returns the CPU brand
*function PlatformInfo.getCPUBrand()
* @returns {string} brand of CPU
*/
QString getCPUBrand();
};
#endif // hifi_PlatformInfoScriptingInterface_h