diff options
author | Berke Viktor <github.bviktor@outlook.com> | 2014-04-24 12:37:11 +0200 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-04-24 06:55:16 -0400 |
commit | b0497573028c9ce6f04de72ef2c57002217dfeef (patch) | |
tree | ab506fc993a09486a267f479f433a7fa9bcc1e62 /src/common/util.c | |
parent | 5fee31b1f09eb366ee43e15f637f36b14bba881f (diff) |
Replace deprecated GetVersionEx calls with version helpers
Only compiles with 8.1 SDK but runs everywhere Closes #957
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 145 |
1 files changed, 80 insertions, 65 deletions
diff --git a/src/common/util.c b/src/common/util.c index 0549bd6e..4582eec6 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -33,6 +33,7 @@ #include <sys/timeb.h> #include <process.h> #include <io.h> +#include <VersionHelpers.h> #include "../dirent/dirent-win32.h" #include "../../config-win32.h" #else @@ -689,74 +690,88 @@ get_sys_str (int with_cpu) { static char verbuf[64]; static char winver[20]; - OSVERSIONINFOEX osvi; double mhz; - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); - GetVersionEx ((OSVERSIONINFO*) &osvi); - - switch (osvi.dwMajorVersion) + if (IsWindows8Point1OrGreater ()) { - case 5: - switch (osvi.dwMinorVersion) - { - case 1: - strcpy (winver, "XP"); - break; - case 2: - if (osvi.wProductType == VER_NT_WORKSTATION) - { - strcpy (winver, "XP x64 Edition"); - } - else - { - if (GetSystemMetrics(SM_SERVERR2) == 0) - { - strcpy (winver, "Server 2003"); - } - else - { - strcpy (winver, "Server 2003 R2"); - } - } - break; - } - break; - case 6: - switch (osvi.dwMinorVersion) - { - case 0: - if (osvi.wProductType == VER_NT_WORKSTATION) - { - strcpy (winver, "Vista"); - } - else - { - strcpy (winver, "Server 2008"); - } - break; - case 1: - if (osvi.wProductType == VER_NT_WORKSTATION) - { - strcpy (winver, "7"); - } - else - { - strcpy (winver, "Server 2008 R2"); - } - break; - case 2: - if (osvi.wProductType == VER_NT_WORKSTATION) - { - strcpy (winver, "8"); - } - else - { - strcpy (winver, "Server 2012"); - } - break; - } - break; + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2012 R2"); + } + else + { + strcpy (winver, "8.1"); + } + } + else if (IsWindows8OrGreater ()) + { + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2012"); + } + else + { + strcpy (winver, "8"); + } + } + else if (IsWindows7SP1OrGreater ()) + { + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2008 R2 SP1"); + } + else + { + strcpy (winver, "7 SP1"); + } + } + else if (IsWindows7OrGreater ()) + { + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2008 R2"); + } + else + { + strcpy (winver, "7"); + } + } + else if (IsWindowsVistaSP2OrGreater ()) + { + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2008 SP2"); + } + else + { + strcpy (winver, "Vista SP2"); + } + } + else if (IsWindowsVistaSP1OrGreater ()) + { + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2008 SP1"); + } + else + { + strcpy (winver, "Vista SP1"); + } + } + else if (IsWindowsVistaOrGreater ()) + { + if (IsWindowsServer ()) + { + strcpy (winver, "Server 2008"); + } + else + { + strcpy (winver, "Vista"); + } + } + else + { + strcpy (winver, "Unknown"); } mhz = get_mhz (); |