Created
April 23, 2021 09:25
-
-
Save BadCoder1337/3e514c21273f7657fb19ddbae6a61453 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s one method for getting the information you want on a Windows machine. I copied and pasted it from an actual project with some minor modifications, so feel free to clean it up to make more sense. | |
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)); | |
} | |
//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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment