From 733a732f03a44bf8a096b61ec659aa0d3f5409c6 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Thu, 3 Sep 2009 08:16:31 +0200 Subject: [PATCH] Detect Windows server 2008 and Windows server 2008 R2 --- src/misc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/misc.c b/src/misc.c index 4a04ce91..cea9e5c2 100644 --- a/src/misc.c +++ b/src/misc.c @@ -126,15 +126,23 @@ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/ge } else if (Ver.dwMajorVersion == 6 && Ver.dwMinorVersion == 0) { - snprintf(buffer, sizeof(buffer) - 1, "Windows Vista (%lu)", Ver.dwBuildNumber); + if( Ver.wProductType == VER_NT_WORKSTATION ) + snprintf(buffer, sizeof(buffer) - 1, "Windows Vista (%lu)", Ver.dwBuildNumber); + else + snprintf(buffer, sizeof(buffer) - 1, "Windows Server 2008 (%lu)", Ver.dwBuildNumber); } - else if (Ver.dwMajorVersion == 6 && Ver.dwMinorVersion > 0) + else if (Ver.dwMajorVersion == 6 && Ver.dwMinorVersion == 1) { - snprintf(buffer, sizeof(buffer) - 1, "Windows Server 2007 (%lu)", Ver.dwBuildNumber); + if( Ver.wProductType == VER_NT_WORKSTATION ) + snprintf(buffer, sizeof(buffer) - 1, "Windows 7 (%lu)", Ver.dwBuildNumber); + else + snprintf(buffer, sizeof(buffer) - 1, "Windows Server 2008 R2 (%lu)", Ver.dwBuildNumber); } else { - snprintf(buffer, sizeof(buffer) - 1, "Windows %i.%i.%i",(int)Ver.dwMajorVersion,(int)Ver.dwMinorVersion,(int)Ver.dwBuildNumber); + snprintf(buffer, sizeof(buffer) - 1, "Windows %s %i.%i.%i", + (Ver.wProductType == VER_NT_WORKSTATION ? "WorkStation" : Server), + (int)Ver.dwMajorVersion, (int)Ver.dwMinorVersion, (int)Ver.dwBuildNumber); } if (Extended && Ver.wServicePackMajor != 0) {