Merge branch 'upstream-kwsys' into update-kwsys

This commit is contained in:
Brad King 2015-09-14 09:24:05 -04:00
commit ef29f5ef89
1 changed files with 51 additions and 17 deletions

View File

@ -4879,11 +4879,8 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
OSVERSIONINFOEXA osvi; OSVERSIONINFOEXA osvi;
BOOL bOsVersionInfoEx; BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure. ZeroMemory(&osvi, sizeof(osvi));
// If that fails, try using the OSVERSIONINFO structure. osvi.dwOSVersionInfoSize = sizeof(osvi);
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (push) # pragma warning (push)
@ -4893,14 +4890,10 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
# pragma warning (disable:4996) # pragma warning (disable:4996)
# endif # endif
#endif #endif
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi); bOsVersionInfoEx = GetVersionExA((OSVERSIONINFOA *)&osvi);
if (!bOsVersionInfoEx) if (!bOsVersionInfoEx)
{ {
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); return 0;
if (!GetVersionEx((OSVERSIONINFO *)&osvi))
{
return 0;
}
} }
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (pop) # pragma warning (pop)
@ -4913,10 +4906,56 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
case VER_PLATFORM_WIN32_NT: case VER_PLATFORM_WIN32_NT:
// Test for the specific product family. // Test for the specific product family.
if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0)
{
if (osvi.wProductType == VER_NT_WORKSTATION)
{
res += "Microsoft Windows 10";
}
else
{
res += "Microsoft Windows Server 2016 family";
}
}
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3)
{
if (osvi.wProductType == VER_NT_WORKSTATION)
{
res += "Microsoft Windows 8.1";
}
else
{
res += "Microsoft Windows Server 2012 R2 family";
}
}
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2)
{
if (osvi.wProductType == VER_NT_WORKSTATION)
{
res += "Microsoft Windows 8";
}
else
{
res += "Microsoft Windows Server 2012 family";
}
}
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1)
{
if (osvi.wProductType == VER_NT_WORKSTATION)
{
res += "Microsoft Windows 7";
}
else
{
res += "Microsoft Windows Server 2008 R2 family";
}
}
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
{ {
#if (_MSC_VER >= 1300)
if (osvi.wProductType == VER_NT_WORKSTATION) if (osvi.wProductType == VER_NT_WORKSTATION)
{ {
res += "Microsoft Windows Vista"; res += "Microsoft Windows Vista";
@ -4925,9 +4964,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
{ {
res += "Microsoft Windows Server 2008 family"; res += "Microsoft Windows Server 2008 family";
} }
#else
res += "Microsoft Windows Vista or Windows Server 2008";
#endif
} }
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
@ -4956,7 +4992,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
{ {
// Test for the workstation type. // Test for the workstation type.
#if (_MSC_VER >= 1300)
if (osvi.wProductType == VER_NT_WORKSTATION) if (osvi.wProductType == VER_NT_WORKSTATION)
{ {
if (osvi.dwMajorVersion == 4) if (osvi.dwMajorVersion == 4)
@ -5028,7 +5063,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
} }
} }
} }
#endif // Visual Studio 7 and up
} }
// Test for specific product on Windows NT 4.0 SP5 and earlier // Test for specific product on Windows NT 4.0 SP5 and earlier