/* wver.c - Muestra la versión del sistema operativo Copyright(C) 2001-2003, Luis Carlos Castro Skertchly This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Cambios 1.0 - Version inicial para Windows 9x/NT 1.1 - Soporte para Windows 2000 y XP 1.2 - Soporte para Windows Server 2003 y versiones futuras de Windows */ #include #include OSVERSIONINFOEX osvi; BOOL bOsVersionInfoEx; BOOL bFullInfo; char szVersion[80]; char *szProductType; int main(int argc, char **argv) { bFullInfo = FALSE; if (argc > 1) { if (!lstrcmpi(argv[1], "/?")) { printf("WVER 1.2 - Show Windows version\n" "Copyright (C) 1999-2003, Luis C. Castro Skertchly (lc_castro@yahoo.com)\n" "Usage: wver [/f]\n" "\t/f Print 'raw' information returned by OS\n\n"); return 1; } if (!lstrcmpi(argv[1], "/F")) bFullInfo = TRUE; } ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi))) { // Si OSVERSIONINFOEX no funciona, usar OSVERSIONINFO osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx((OSVERSIONINFO *) &osvi)) { printf("Error %d calling GetVersionEx()\n", GetLastError()); return 1; } } if (bFullInfo) { printf("Version: %d.%d\n", osvi.dwMajorVersion, osvi.dwMinorVersion); printf("Build: %d\n", osvi.dwBuildNumber & 0xFFFF); printf("Platform ID: "); switch(osvi.dwPlatformId) { case VER_PLATFORM_WIN32s: printf("VER_PLAFTORM_WIN32s"); break; case VER_PLATFORM_WIN32_WINDOWS: printf("VER_PLATFORM_WIN32_WINDOWS"); break; case VER_PLATFORM_WIN32_NT: printf("VER_PLATFORM_WIN32_NT"); break; default: printf(""); } printf(" (0x%04X%04X)\n", HIWORD(osvi.dwPlatformId), LOWORD(osvi.dwPlatformId)); printf("CSDVersion: '%s'\n", osvi.szCSDVersion); if (bOsVersionInfoEx) { printf("Service Pack: %d.%d\n", osvi.wServicePackMajor, osvi.wServicePackMinor); printf("Suite Mask (0x%04x): ", osvi.wSuiteMask); #define IFMASK(x) if (osvi.wSuiteMask & x) IFMASK(VER_SUITE_BACKOFFICE) printf("VER_SUITE_BACKOFFICE "); IFMASK(VER_SUITE_BLADE) printf("VER_SUITE_BLADE "); IFMASK(VER_SUITE_DATACENTER) printf("VER_SUITE_DATACENTER "); IFMASK(VER_SUITE_ENTERPRISE) printf("VER_SUITE_ENTERPRISE "); IFMASK(VER_SUITE_PERSONAL) printf("VER_SUITE_PERSONAL "); IFMASK(VER_SUITE_SMALLBUSINESS) printf("VER_SUITE_SMALLBUSINESS"); IFMASK(VER_SUITE_SMALLBUSINESS_RESTRICTED) printf("VER_SUITE_SMALLBUSINESS_RESTRICTED "); IFMASK(VER_SUITE_TERMINAL) printf ("VER_SUITE_TERMINAL"); printf("\n"); printf("Product Type: "); switch(osvi.wProductType) { case VER_NT_WORKSTATION: printf("VER_NT_WORKSTATION"); break; case VER_NT_DOMAIN_CONTROLLER: printf("VER_NT_DOMAIN_CONTROLLER"); break; case VER_NT_SERVER: printf("VER_NT_SERVER"); break; default: printf("UNKNOWN"); } printf(" (0x%04X)", osvi.wProductType); printf("\n\n"); } } if (osvi.dwPlatformId == VER_PLATFORM_WIN32s) printf("Microsoft Win32s in Windows %d.%d (Build %d) %s", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) printf("Microsoft Windows 95%s %d.%d (Build %d) %s", (osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B') ? " OSR2" : NULL, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); else if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) { printf("Microsoft Windows 98%s %d.%d (Build %d) %s", (osvi.szCSDVersion[1] == 'A') ? " SE" : NULL, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); } else if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { printf("Microsoft Windows Millenium Edition %d.%d (Build %d) %s", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); } else { printf("Microsoft Windows %d.%d (Build %d) %s", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); } } else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { if (osvi.dwMajorVersion <= 4) { switch (osvi.wProductType) { case VER_NT_WORKSTATION: szProductType = "Workstation"; break; case VER_NT_SERVER: szProductType = "Server"; if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) szProductType = "Server Enterprise Edition"; break; case VER_NT_DOMAIN_CONTROLLER: szProductType = "Advanced Server"; if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) szProductType = "Advanced Server Enterprise Edition"; break; } printf("Microsoft Windows NT %d.%d %s (Build %d) %s", osvi.dwMajorVersion, osvi.dwMinorVersion, szProductType, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); return 0; } else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) { switch (osvi.wProductType) { case VER_NT_WORKSTATION: szProductType = "2000 Professional"; break; case VER_NT_SERVER: if (osvi.wSuiteMask & VER_SUITE_DATACENTER) szProductType = "2000 Datacenter Server"; else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) szProductType = "2000 Advanced Server"; else szProductType = "2000 Server"; break; case VER_NT_DOMAIN_CONTROLLER: szProductType = "2000 Advanced Server (Domain Controller)"; break; } } else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { switch (osvi.wProductType) { case VER_NT_WORKSTATION: if (osvi.wSuiteMask & VER_SUITE_PERSONAL) szProductType = "XP Home Edition"; else szProductType = "XP Professional"; break; case VER_NT_SERVER: if (osvi.wSuiteMask & VER_SUITE_DATACENTER) szProductType = "XP DataCenter Server"; else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) szProductType = ".NET Enterprise Server"; else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) szProductType = ".NET Web Server"; break; case VER_NT_DOMAIN_CONTROLLER: szProductType = "{XP|NET} VER_NT_DOMAIN_CONTROLLER"; break; } } else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { switch (osvi.wProductType) { case VER_NT_WORKSTATION: szProductType = "2003 Workstation (??)"; break; case VER_NT_SERVER: if (osvi.wSuiteMask & VER_SUITE_DATACENTER) szProductType = "Server 2003 Datacenter Server"; else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) szProductType = "Server 2003 Enterprise Edition"; else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) szProductType = "Server 2003 Personal (??)"; else if (osvi.wSuiteMask & VER_SUITE_BLADE) szProductType = "Server 2003 Web Edition"; else szProductType = "Server 2003 Standard Edition"; break; } } else { switch (osvi.wProductType) { case VER_NT_WORKSTATION: szProductType = " Workstation"; break; case VER_NT_SERVER: szProductType = " Server"; break; } } printf("Microsoft Windows %s (Build %d) %s", szProductType, osvi.dwBuildNumber & 0xFFFF, osvi.szCSDVersion); } return 0; }