Update Windows CPU name lookup

This commit is contained in:
Brett Williams
2025-12-27 21:14:28 -06:00
parent 87544d81a9
commit 0f6082701a

View File

@@ -148,10 +148,21 @@ def current_system_cpu_brand():
except Exception:
pass
elif sys.platform.startswith('win'): # Windows
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
try:
return platform.processor() # Often sufficient, or fallback to env var
# Open the registry key where Windows stores the CPU name
key = OpenKey(HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0")
# The value name is "ProcessorNameString"
value, _ = QueryValueEx(key, "ProcessorNameString")
return value.strip() # Usually perfect, with full marketing name
except Exception:
pass
# Fallback: sometimes the key is under a different index, try 1
try:
key = OpenKey(HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\1")
value, _ = QueryValueEx(key, "ProcessorNameString")
return value.strip()
except Exception:
return "Unknown CPU"
elif sys.platform.startswith('linux'):
try:
with open('/proc/cpuinfo') as f: