2013-11-06 21:25:21 +01:00
|
|
|
#if __linux__
|
2017-01-04 15:17:35 -02:00
|
|
|
#define OS_PLATFORM_LINUX
|
2013-11-06 21:25:21 +01:00
|
|
|
#elif TARGET_OS_MAC
|
2017-01-04 15:17:35 -02:00
|
|
|
#define OS_PLATFORM_MAC
|
2013-11-06 21:25:21 +01:00
|
|
|
#elif defined _WIN32 || defined _WIN64
|
2017-01-04 15:17:35 -02:00
|
|
|
#define OS_PLATFORM_WINDOWS
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <VersionHelpers.h> // Requires windows 8.1 sdk at least
|
2013-11-06 21:25:21 +01:00
|
|
|
#endif
|
|
|
|
|
2016-12-03 19:04:58 +09:00
|
|
|
#include "VersionInfo.h"
|
|
|
|
|
2016-12-03 18:23:47 +09:00
|
|
|
std::string VersionInfo::GetVersionInfo() {
|
2013-11-06 21:25:21 +01:00
|
|
|
#if defined(OS_PLATFORM_LINUX)
|
2013-11-07 00:40:03 +10:00
|
|
|
return std::string("Linux");
|
2013-11-06 21:25:21 +01:00
|
|
|
#elif defined(TARGET_OS_MAC)
|
2013-11-07 00:40:03 +10:00
|
|
|
return std::string("Mac OS X");
|
2016-12-03 18:23:47 +09:00
|
|
|
#elif defined(OS_PLATFORM_WINDOWS)
|
2017-01-04 15:17:35 -02:00
|
|
|
|
2017-01-05 02:13:04 +02:00
|
|
|
std::string windowsVersion;
|
|
|
|
|
|
|
|
if (IsWindowsXPOrGreater() && !IsWindowsVistaOrGreater()) {
|
|
|
|
windowsVersion = "Windows XP";
|
2017-01-05 16:13:43 +02:00
|
|
|
} else if (IsWindowsVistaOrGreater() && !IsWindows7OrGreater()) {
|
2017-01-05 02:13:04 +02:00
|
|
|
windowsVersion = "Windows Vista";
|
2017-01-05 16:13:43 +02:00
|
|
|
} else if (IsWindows7OrGreater() && !IsWindows8OrGreater()) {
|
2017-01-05 02:13:04 +02:00
|
|
|
windowsVersion = "Windows 7";
|
2017-01-05 16:13:43 +02:00
|
|
|
} else if (IsWindows8OrGreater() && !IsWindows8Point1OrGreater()) {
|
2017-01-05 02:13:04 +02:00
|
|
|
windowsVersion = "Windows 8";
|
2017-01-05 16:13:43 +02:00
|
|
|
} else if (IsWindows8Point1OrGreater()) {
|
2017-01-05 02:13:04 +02:00
|
|
|
windowsVersion = "Windows 8.1";
|
2017-01-05 16:13:43 +02:00
|
|
|
} else {
|
|
|
|
// Default to Windows 10
|
|
|
|
// See https://github.com/yvt/openspades/pull/528 for reason.
|
|
|
|
windowsVersion = "Windows 10";
|
2017-01-05 02:13:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Might be a greater version, but the new Microsoft
|
|
|
|
// API doesn't support checking for specific versions.
|
|
|
|
|
|
|
|
if (IsWindowsServer())
|
|
|
|
windowsVersion += " Server";
|
|
|
|
return windowsVersion;
|
2017-01-27 20:32:47 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
return std::string("FreeBSD");
|
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
return std::string("OpenBSD");
|
2013-11-06 21:25:21 +01:00
|
|
|
#else
|
2013-11-07 00:40:03 +10:00
|
|
|
return std::string("Unknown OS");
|
2013-11-06 21:25:21 +01:00
|
|
|
#endif
|
2017-01-27 20:32:47 +00:00
|
|
|
}
|