wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) { static struct { bool initialized; wxOperatingSystemId os; int verMaj, verMin; } s_version; // query the OS info only once as it's not supposed to change if ( !s_version.initialized ) { const OSVERSIONINFOEX info = wxGetWindowsVersionInfo(); s_version.initialized = true; #if defined(__WXWINCE__) s_version.os = wxOS_WINDOWS_CE; #else // "normal" desktop Windows system, use run-time detection switch ( info.dwPlatformId ) { case VER_PLATFORM_WIN32_NT: s_version.os = wxOS_WINDOWS_NT; break; case VER_PLATFORM_WIN32_WINDOWS: s_version.os = wxOS_WINDOWS_9X; break; } #endif // Windows versions s_version.verMaj = info.dwMajorVersion; s_version.verMin = info.dwMinorVersion; } if ( verMaj ) *verMaj = s_version.verMaj; if ( verMin ) *verMin = s_version.verMin; return s_version.os; }
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { static struct { bool initialized; wxOperatingSystemId os; int verMaj, verMin, verMicro; } s_version; // query the OS info only once as it's not supposed to change if ( !s_version.initialized ) { const OSVERSIONINFOEXW info = wxGetWindowsVersionInfo(); s_version.initialized = true; switch ( info.dwPlatformId ) { case VER_PLATFORM_WIN32_NT: s_version.os = wxOS_WINDOWS_NT; break; case VER_PLATFORM_WIN32_WINDOWS: s_version.os = wxOS_WINDOWS_9X; break; } s_version.verMaj = info.dwMajorVersion; s_version.verMin = info.dwMinorVersion; s_version.verMicro = info.dwBuildNumber; } if ( verMaj ) *verMaj = s_version.verMaj; if ( verMin ) *verMin = s_version.verMin; if ( verMicro ) *verMicro = s_version.verMicro; return s_version.os; }
wxString wxGetOsDescription() { wxString str; const OSVERSIONINFOEX info = wxGetWindowsVersionInfo(); switch ( info.dwPlatformId ) { #ifdef VER_PLATFORM_WIN32_CE case VER_PLATFORM_WIN32_CE: str.Printf(_("Windows CE (%d.%d)"), info.dwMajorVersion, info.dwMinorVersion); break; #endif case VER_PLATFORM_WIN32s: str = _("Win32s on Windows 3.1"); break; case VER_PLATFORM_WIN32_WINDOWS: switch (info.dwMinorVersion) { case 0: if ( info.szCSDVersion[1] == 'B' || info.szCSDVersion[1] == 'C' ) { str = _("Windows 95 OSR2"); } else { str = _("Windows 95"); } break; case 10: if ( info.szCSDVersion[1] == 'B' || info.szCSDVersion[1] == 'C' ) { str = _("Windows 98 SE"); } else { str = _("Windows 98"); } break; case 90: str = _("Windows ME"); break; default: str.Printf(_("Windows 9x (%d.%d)"), info.dwMajorVersion, info.dwMinorVersion); break; } if ( !wxIsEmpty(info.szCSDVersion) ) { str << wxT(" (") << info.szCSDVersion << wxT(')'); } break; case VER_PLATFORM_WIN32_NT: switch ( info.dwMajorVersion ) { case 5: switch ( info.dwMinorVersion ) { case 0: str = _("Windows 2000"); break; case 2: // we can't distinguish between XP 64 and 2003 // as they both are 5.2, so examine the product // type to resolve this ambiguity if ( wxIsWindowsServer() == 1 ) { str = _("Windows Server 2003"); break; } //else: must be XP, fall through case 1: str = _("Windows XP"); break; } break; case 6: switch ( info.dwMinorVersion ) { case 0: str = wxIsWindowsServer() == 1 ? _("Windows Server 2008") : _("Windows Vista"); break; case 1: str = wxIsWindowsServer() == 1 ? _("Windows Server 2008 R2") : _("Windows 7"); break; case 2: str = wxIsWindowsServer() == 1 ? _("Windows Server 2012") : _("Windows 8"); break; case 3: str = wxIsWindowsServer() == 1 ? _("Windows Server 2012 R2") : _("Windows 8.1"); break; } break; case 10: str = wxIsWindowsServer() == 1 ? _("Windows Server 10") : _("Windows 10"); break; } if ( str.empty() ) { str.Printf(_("Windows NT %lu.%lu"), info.dwMajorVersion, info.dwMinorVersion); } str << wxT(" (") << wxString::Format(_("build %lu"), info.dwBuildNumber); if ( !wxIsEmpty(info.szCSDVersion) ) { str << wxT(", ") << info.szCSDVersion; } str << wxT(')'); if ( wxIsPlatform64Bit() ) str << _(", 64-bit edition"); break; } return str; }