Single‑header, modern C++ library to query every corner of Windows
No external dependencies, no DLLs – just #include and go.
#include "syswin.hpp"
std::string cpu = syswin::get_cpu_name(); // "Intel Core i7-9700K @ 3.60GHz"| Category | What you can get |
|---|---|
| 💻 Hardware | CPU name, physical/logical cores, GPU name, total RAM, disk info (size, free space, file system) |
| 📈 Live telemetry | CPU usage (delta), RAM used/free (GB), current process memory |
| ⚙️ Processes | List all running processes (PID, name, path, memory), kill a process by PID |
| 🚀 Startup | Read/write/delete HKCU/HKLM Run entries with environment variable expansion |
| 🧠 OS & System | Windows version (real), build number, uptime, computer name, architecture, system directories |
| 👑 Administrator | Check admin rights, check elevation level, relaunch as admin (UAC) |
| 📦 Installed SW | Enumerate 32/64‑bit installed applications from registry (name, version, publisher, uninstall) |
| 👤 Current user | Username, domain, SID |
| 🌐 Network | List adapters (name, MAC, speed, status), get local IPv4/IPv6, get MAC address |
| 🔋 Battery | Percentage, charging state, remaining minutes (laptops) |
| 🛠️ Windows Services | List all services with status (Running/Stopped) and startup type (Auto/Manual/Disabled) |
| 🎤 Audio devices | Count and details of output/input devices (WinMM) |
| 🌍 Environment | Get all variables or a specific one |
Just copy syswin.hpp into your project and include it.
That’s it – no build steps, no extra libraries. All necessary .lib files are automatically linked via #pragma comment.
git clone https://github.com/yourname/syswin.git
cd your_project
cp syswin/syswin.hpp .#include <iostream>
#include "syswin.hpp"
int main() {
// Basic hardware
std::cout << "CPU : " << syswin::get_cpu_name() << "\n";
std::cout << "GPU : " << syswin::get_gpu_name() << "\n";
std::cout << "RAM : " << syswin::get_total_ram_gb() << " GB total\n";
// Live CPU usage (need two calls)
syswin::get_cpu_usage(); // first call – baseline
Sleep(1000);
unsigned cpu = syswin::get_cpu_usage();
std::cout << "CPU usage: " << cpu << "%\n";
// Network
std::wcout << L"Your IP : " << syswin::get_local_ipv4() << L"\n";
return 0;
}auto cores = syswin::get_cpu_cores();
std::cout << "Physical cores: " << cores.physical_cores
<< ", Logical cores: " << cores.logical_cores << "\n";
for (const auto& disk : syswin::get_disks_info()) {
std::wcout << L"Drive " << disk.drive_letter
<< L" – " << disk.total_bytes / (1024*1024*1024) << L" GB total, "
<< disk.free_bytes / (1024*1024*1024) << L" GB free\n";
}for (const auto& proc : syswin::get_running_processes()) {
std::wcout << L"PID " << proc.pid
<< L" : " << proc.name
<< L" [" << proc.memory_mb << L" MB]\n";
}
// Kill a process (use with care)
syswin::terminate_process(12345);// Add current user startup
syswin::add_startup_current_user(L"MyApp", L"C:\\tools\\myapp.exe --quiet");
// Read all
auto cmds = syswin::get_startup_commands();
for (auto& cmd : cmds) std::wcout << cmd << L"\n";
// Remove
syswin::remove_startup_current_user(L"MyApp");if (!syswin::is_admin()) {
if (syswin::run_as_admin()) {
return 0; // new elevated process launched, exit this one
} else {
std::cerr << "User cancelled UAC prompt.\n";
}
}
// Here we are elevatedstd::wcout << L"IPv4: " << syswin::get_local_ipv4() << L"\n";
std::wcout << L"MAC : " << syswin::get_mac_address() << L"\n";
for (const auto& a : syswin::get_network_adapters()) {
std::wcout << L"Adapter: " << a.name
<< L", Speed: " << a.speed_mbps << L" Mbps"
<< L", MAC: " << a.mac_address << L"\n";
}auto sw = syswin::get_installed_software();
for (const auto& prog : sw) {
std::wcout << prog.name << L" v" << prog.version
<< L" by " << prog.publisher << L"\n";
}auto bat = syswin::get_battery_status();
if (bat.is_battery_present) {
std::cout << "Battery: " << bat.percentage << "%";
if (bat.is_charging) std::cout << " (charging)";
if (bat.remaining_minutes >= 0)
std::cout << ", " << bat.remaining_minutes << " min left";
std::cout << "\n";
}auto services = syswin::get_services();
for (const auto& svc : services) {
std::wcout << svc.name << L" – " << svc.status
<< L" (start: " << svc.start_type << L")\n";
}std::wstring path = syswin::get_env_var(L"PATH");
auto all = syswin::get_all_env_vars();
for (auto& [name, value] : all) {
// do something
}| Note | Description |
|---|---|
| CPU usage | First call returns 0 (baseline). Subsequent calls give usage since last call. Thread‑safe. |
| Winsock | Network functions automatically initialise/cleanup Winsock with reference counting. No manual WSAStartup. |
| Registry | HKLM uninstall keys are read with both 32‑ and 64‑bit views. Startup write needs admin rights for HKLM. |
| Process memory | Some protected processes may return 0 MB due to insufficient privileges. |
| Strings | Most functions return std::wstring (UTF‑16). Use syswin::to_utf8() / syswin::to_wstring() to convert. |
| Thread safety | All functions are thread‑safe unless noted (get_cpu_usage() uses a mutex). |
| Elevation | run_as_admin() does not exit the current process – you should do that yourself after the call. |
- OS: Windows Vista,Windows 7,Windows 10,Windows 11
- Compiler: Any C++17 compiler (MSVC 2019+, Clang-cl, MinGW-w64 11+).
- No external dependencies – pure Win32 API.
The library automatically links:
psapi.libadvapi32.libiphlpapi.libwinmm.libws2_32.libshell32.lib
All functions are inside namespace syswin and are inline.
std::string get_cpu_name()CpuCoreInfo get_cpu_cores()std::string get_gpu_name()unsigned long long get_total_ram_gb()std::vector<DiskInfo> get_disks_info()
unsigned get_cpu_usage()RamUsage get_ram_usage()unsigned long long get_current_process_memory_mb()
std::vector<Process> get_running_processes()bool terminate_process(DWORD pid)std::vector<std::wstring> get_startup_commands()bool add_startup_current_user(...),remove_...,add_startup_local_machine,remove_...
std::wstring get_windows_version(),DWORD get_windows_build_number()unsigned long long get_system_uptime_seconds()std::wstring get_computer_name(),get_system_directory(),get_windows_directory()std::string get_os_architecture()
bool is_admin(),bool is_process_elevated(),bool run_as_admin(const std::wstring& parameters = L"")
std::vector<InstalledProgram> get_installed_software()
std::wstring get_current_username(),get_current_user_domain(),get_current_user_sid()
std::vector<NetworkAdapter> get_network_adapters()std::wstring get_local_ipv4(),get_local_ipv6(),get_mac_address()
BatteryStatus get_battery_status()
std::vector<ServiceInfo> get_services()
unsigned int get_audio_output_devices_count(),get_audio_input_devices_count()std::vector<AudioDeviceInfo> get_audio_output_devices(),get_audio_input_devices()
std::vector<std::pair<std::wstring, std::wstring>> get_all_env_vars()std::wstring get_env_var(const std::wstring& name)
std::string to_utf8(const std::wstring&)std::wstring to_wstring(const std::string&)
MIT License – see the header file for full text.