refactor
This commit is contained in:
parent
32e7e0b2b7
commit
205c4b78f7
1 changed files with 3 additions and 14 deletions
|
@ -116,26 +116,15 @@ static std::string get_cpu_info() {
|
||||||
}
|
}
|
||||||
char cpu_brand[256];
|
char cpu_brand[256];
|
||||||
DWORD cpu_brand_size = sizeof(cpu_brand);
|
DWORD cpu_brand_size = sizeof(cpu_brand);
|
||||||
if (RegQueryValueEx(hKey,
|
if (RegQueryValueExA(hKey,
|
||||||
TEXT("ProcessorNameString"),
|
TEXT("ProcessorNameString"),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)cpu_brand,
|
(LPBYTE)cpu_brand,
|
||||||
&cpu_brand_size) != ERROR_SUCCESS) {
|
&cpu_brand_size) == ERROR_SUCCESS) {
|
||||||
RegCloseKey(hKey);
|
id.assign(cpu_brand, cpu_brand_size);
|
||||||
// fail to read processor information
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
// ensure the string is null-terminated
|
|
||||||
if (cpu_brand_size >= sizeof(cpu_brand)) {
|
|
||||||
cpu_brand[sizeof(cpu_brand) - 1] = '\0';
|
|
||||||
} else {
|
|
||||||
cpu_brand[cpu_brand_size] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
id = std::string(cpu_brand);
|
|
||||||
#endif
|
#endif
|
||||||
// TODO: other platforms
|
// TODO: other platforms
|
||||||
return id;
|
return id;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue