Query the operating system information */
| 5325 | |
| 5326 | /** Query the operating system information */ |
| 5327 | bool SystemInformationImplementation::QueryOSInformation() |
| 5328 | { |
| 5329 | #if defined(_WIN32) |
| 5330 | |
| 5331 | this->OSName = "Windows"; |
| 5332 | |
| 5333 | OSVERSIONINFOEXW osvi = { sizeof(osvi) }; |
| 5334 | # ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx |
| 5335 | # pragma warning(push) |
| 5336 | # ifdef __INTEL_COMPILER |
| 5337 | # pragma warning(disable : 1478) |
| 5338 | # elif defined __clang__ |
| 5339 | # pragma clang diagnostic push |
| 5340 | # pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| 5341 | # else |
| 5342 | # pragma warning(disable : 4996) |
| 5343 | # endif |
| 5344 | # endif |
| 5345 | if (!GetVersionExW((OSVERSIONINFOW*)&osvi)) { |
| 5346 | return false; |
| 5347 | } |
| 5348 | # ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx |
| 5349 | # ifdef __clang__ |
| 5350 | # pragma clang diagnostic pop |
| 5351 | # else |
| 5352 | # pragma warning(pop) |
| 5353 | # endif |
| 5354 | # endif |
| 5355 | |
| 5356 | // Produce the release like it is displayed in `cmd` |
| 5357 | this->OSRelease = std::to_string(osvi.dwMajorVersion) + "." + |
| 5358 | std::to_string(osvi.dwMinorVersion) + "." + |
| 5359 | std::to_string(osvi.dwBuildNumber & 0xFFFF); |
| 5360 | |
| 5361 | struct VersionNames |
| 5362 | { |
| 5363 | char const* workstation; |
| 5364 | char const* server; |
| 5365 | }; |
| 5366 | |
| 5367 | std::map<std::pair<DWORD, DWORD>, VersionNames> const products = { |
| 5368 | // clang-format off |
| 5369 | { { 10, 0 }, { "10", "2016" } }, |
| 5370 | { { 6, 3 }, { "8.1", "2012 R2" } }, |
| 5371 | { { 6, 2 }, { "8", "2012" } }, |
| 5372 | { { 6, 1 }, { "7", "2008 R2" } }, |
| 5373 | { { 6, 0 }, { "Vista", "2008" } }, |
| 5374 | { { 5, 2 }, { "XP", "2003" } }, |
| 5375 | { { 5, 1 }, { "XP", ".NET" } }, |
| 5376 | { { 5, 0 }, { "2000", "2000" } }, |
| 5377 | { { 4, 90 }, { "Me", "" } }, |
| 5378 | { { 4, 10 }, { "98", "" } }, |
| 5379 | { { 4, 0 }, { "95", "NT 4.0" } }, |
| 5380 | { { 3, 51 }, { "", "NT 3.51" } }, |
| 5381 | { { 3, 10 }, { "3.1", "" } }, |
| 5382 | { { 3, 0 }, { "3.0", "" } }, |
| 5383 | { { 2, 0 }, { "2.0", "" } }, |
| 5384 | // clang-format on |
no test coverage detected