Created
November 2, 2025 22:32
-
-
Save su8/eeaaf275cff551548e8ab53d4e549475 to your computer and use it in GitHub Desktop.
sys.cpp
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
| #include <iostream> | |
| #include <cstdio> | |
| #include <string> | |
| #include <cstdlib> | |
| #include <cstring> | |
| #include <windows.h> | |
| #define WIN32_LEAN_AND_MEAN | |
| int main(void) { | |
| OSVERSIONINFO kernel; | |
| ZeroMemory(&kernel, sizeof(OSVERSIONINFO)); | |
| kernel.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | |
| GetVersionEx(&kernel); | |
| std::cout << "Windows NT " << kernel.dwMajorVersion << "." << kernel.dwMinorVersion << " build " << kernel.dwBuildNumber << std::endl; | |
| char cpu[256] = {'\0'}; | |
| char gpu[256] = {'\0'}; | |
| HKEY hkey; | |
| DWORD len = 256; | |
| RegOpenKey(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hkey); | |
| RegQueryValueEx(hkey, "ProcessorNameString", 0, NULL, (BYTE *)cpu, &len); | |
| RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\\ControlSet001\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}\\0000\\Settings", &hkey); | |
| RegQueryValueEx(hkey, "Device Description", 0, NULL, (BYTE *)gpu, &len); | |
| std::cout << "CPU: " << cpu << std::endl; | |
| std::cout << "GPU: " << gpu << std::endl; | |
| return EXIT_SUCCESS; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment