MCPcopy Create free account
hub / github.com/SaschaWillems/VulkanCapsViewer / getOperatingSystem

Function getOperatingSystem

vulkanCapsViewer.cpp:81–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79const QString VulkanCapsViewer::reportVersion = "4.1";
80
81OSInfo getOperatingSystem()
82{
83 // QSysInfo works for all supported operating systems
84 OSInfo osInfo = {};
85 osInfo.name = QSysInfo::productType().toStdString();
86 osInfo.architecture = QSysInfo::buildCpuArchitecture().toStdString();
87 osInfo.version = QSysInfo::productVersion().toStdString();
88 // The Qt version used does not detect Windows 11, so we use Win32 API to detect it via the build version
89#if defined(_WIN32)
90 HMODULE hModule = LoadLibrary(TEXT("ntdll.dll"));
91 if (hModule) {
92 typedef NTSTATUS(WINAPI* RtlGetVersionFN)(PRTL_OSVERSIONINFOW);
93 RtlGetVersionFN RtlGetVersion = reinterpret_cast<RtlGetVersionFN>(GetProcAddress(hModule, "RtlGetVersion"));
94 if (RtlGetVersion) {
95 RTL_OSVERSIONINFOW osVersionInfo = { 0 };
96 osVersionInfo.dwOSVersionInfoSize = sizeof(osVersionInfo);
97 if (RtlGetVersion(&osVersionInfo) == S_OK) {
98 if (osVersionInfo.dwBuildNumber >= 22000) {
99 osInfo.version = "11";
100 }
101 }
102 }
103 FreeLibrary(hModule);
104 }
105#endif
106 // Also store os type lookup value used by the database (more precise than doing guesswork in a database trigger)
107#if defined(VK_USE_PLATFORM_WIN32_KHR)
108 osInfo.type = 0;
109#endif
110#if defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
111 osInfo.type = 1;
112#endif
113#if defined(VK_USE_PLATFORM_ANDROID_KHR)
114 osInfo.type = 2;
115#endif
116#if defined(VK_USE_PLATFORM_METAL_EXT)
117 osInfo.type = 3;
118#endif
119
120 return osInfo;
121}
122
123// Convert a list variant into an imploded string
124QString arrayToStr(QVariant value) {

Callers 1

getGPUinfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected