Extend SystemInfo

This commit is contained in:
2021-08-02 02:26:18 +02:00
parent 2829c02762
commit 16f76fa04b
4 changed files with 659 additions and 1 deletions

View File

@@ -9,6 +9,9 @@
#include <iostream>
#include <Windows.h>
#include <Psapi.h>
#include <Lmcons.h>
#include <Winsock.h>
#include <Winbase.h>
namespace openVulkanoCpp
{
@@ -79,4 +82,158 @@ namespace openVulkanoCpp
{
return ReadAppMemInfo(APP_MEM_TYPE::VM_MAX);
}
std::string SystemInfo::GetUserName()
{
char username[UNLEN+1];
DWORD username_len = UNLEN+1;
GetUserName(username, &username_len);
return username;
}
std::string SystemInfo::GetHostName()
{
char hostname[UNLEN+1];
gethostname(hostname, UNLEN+1);
return hostname;
}
std::string SystemInfo::GetDeviceName()
{
char computerName[UNLEN+1];
DWORD computerName_len = UNLEN+1;
GetComputerNameA(computerName, &computerName_len);
return computerName;
}
std::string SystemInfo::GetDeviceVendorName()
{
return "Microsoft"; //TODO
}
std::string SystemInfo::GetDeviceModelName()
{
return "Unknown"; //TODO
}
std::string SystemInfo::GetOsName()
{
return "Windows";
}
Version SystemInfo::GetOsVersion()
{
OSVERSIONINFOEX info;
ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx(&info);
return { info.dwMajorVersion, info.dwMinorVersion, 0, info.dwBuildNumber };
}
std::string SystemInfo::GetOsNameHumanReadable()
{
OSVERSIONINFOEX info;
ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx(&info);
if (info.wProductType == VER_NT_WORKSTATION)
{
if (info.dwMajorVersion == 10)
return "Windows 10";
else if (info.dwMajorVersion == 6)
{
switch (info.dwMinorVersion)
{
case 0: return "Windows Vista";
case 1: return "Windows 7";
case 2: return "Windows 8";
case 3: return "Windows 8.1";
}
}
return "Windows " + std::string(info.dwMajorVersion) + "." + std::string(info.dwMinorVersion);
}
else
{
if (info.dwMajorVersion == 10)
return "Windows Server 2016";
else if (info.dwMajorVersion == 6)
{
switch (info.dwMinorVersion)
{
case 0: return "Windows Server 2008";
case 1: return "Windows Server 2008 R2";
case 2: return "Windows Server 2012";
case 3: return "Windows Server 2012 R2";
}
}
return "Windows Server " + std::string(info.dwMajorVersion) + "." + std::string(info.dwMinorVersion);
}
}
DeviceType SystemInfo::GetDeviceType()
{
return DeviceType::PC;
}
size_t SystemInfo::GetCpuCoreCount()
{
return 0; //TODO
}
size_t SystemInfo::GetCpuThreadCount()
{
return std::thread::hardware_concurrency();
}
int32_t SystemInfo::GetCpuTemperature()
{
return 0; //TODO
}
CpuThermalState SystemInfo::GetCpuThermalState()
{
return CpuThermalState::Normal;
}
bool SystemInfo::IsDeviceInLowPowerMode()
{
return false; //TODO
}
BatteryState SystemInfo::GetDeviceBatteryState()
{
return BatteryState::Unavailable; //TODO
}
float SystemInfo::GetDeviceBatteryLevel()
{
return 0; //TODO
}
void SystemInfo::EnableEnergyEvents()
{
//TODO
}
bool SystemInfo::IsMultitaskingSupported()
{
return true;
}
DeviceOrientation SystemInfo::GetDeviceOrientation()
{
return DeviceOrientation::LandscapeRight; //TODO
}
void SystemInfo::EnableDeviceOrientationEvents()
{
//TODO
}
InterfaceOrientation SystemInfo::GetInterfaceOrientation()
{
return InterfaceOrientation::Landscape; //TODO
}
}