1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-26 03:02:17 -05:00

Replace deprecated GetVersionEx calls with version helpers

Only compiles with 8.1 SDK but runs everywhere

Closes #957
This commit is contained in:
Berke Viktor 2014-04-24 12:37:11 +02:00 committed by TingPing
parent 5fee31b1f0
commit b049757302

View File

@ -33,6 +33,7 @@
#include <sys/timeb.h> #include <sys/timeb.h>
#include <process.h> #include <process.h>
#include <io.h> #include <io.h>
#include <VersionHelpers.h>
#include "../dirent/dirent-win32.h" #include "../dirent/dirent-win32.h"
#include "../../config-win32.h" #include "../../config-win32.h"
#else #else
@ -689,74 +690,88 @@ get_sys_str (int with_cpu)
{ {
static char verbuf[64]; static char verbuf[64];
static char winver[20]; static char winver[20];
OSVERSIONINFOEX osvi;
double mhz; double mhz;
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); if (IsWindows8Point1OrGreater ())
GetVersionEx ((OSVERSIONINFO*) &osvi);
switch (osvi.dwMajorVersion)
{ {
case 5: if (IsWindowsServer ())
switch (osvi.dwMinorVersion)
{ {
case 1: strcpy (winver, "Server 2012 R2");
strcpy (winver, "XP");
break;
case 2:
if (osvi.wProductType == VER_NT_WORKSTATION)
{
strcpy (winver, "XP x64 Edition");
} }
else else
{ {
if (GetSystemMetrics(SM_SERVERR2) == 0) strcpy (winver, "8.1");
}
}
else if (IsWindows8OrGreater ())
{ {
strcpy (winver, "Server 2003"); if (IsWindowsServer ())
}
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"); strcpy (winver, "Server 2012");
} }
break; else
{
strcpy (winver, "8");
} }
break; }
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 (); mhz = get_mhz ();