Example #1
0
CStdString CSysInfo::GetKernelVersion()
{
#if defined(TARGET_DARWIN)
  return g_sysinfo.GetUnameVersion();
#elif defined (TARGET_POSIX)
  struct utsname un;
  if (uname(&un)==0)
  {
    return StringUtils::Format("%s %s %s %s", un.sysname, un.release, un.version, un.machine);;
  }

  return "";
#else
  OSVERSIONINFOEX osvi;
  ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(osvi);

  std::string strKernel = "Windows";
  if (GetVersionEx((OSVERSIONINFO *)&osvi))
  {
    switch (GetWindowsVersion())
    {
    case WindowsVersionVista:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" Vista");
      else
        strKernel.append(" Server 2008");
      break;
    case WindowsVersionWin7:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" 7");
      else
        strKernel.append(" Server 2008 R2");
      break;
    case WindowsVersionWin8:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" 8");
      else
        strKernel.append(" Server 2012");
      break;
    case WindowsVersionWin8_1:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" 8.1");
      else
        strKernel.append(" Server 2012 R2");
      break;
    case WindowsVersionFuture:
      strKernel.append(" Unknown Future Version");
      break;
    default:
      strKernel.append(" Unknown version");
      break;
    }

    // Append Service Pack version if any
    if (osvi.wServicePackMajor > 0)
    {
      strKernel.append(StringUtils::Format(" SP%d", osvi.wServicePackMajor));
      if (osvi.wServicePackMinor > 0)
      {
        strKernel.append(StringUtils::Format(".%d", osvi.wServicePackMinor));
      }
    }

    strKernel.append(StringUtils::Format(" %d-bit", GetKernelBitness()));

    strKernel.append(StringUtils::Format(", build %d", osvi.dwBuildNumber));
  }
  else
  {
    strKernel.append(" unknown");
    strKernel.append(StringUtils::Format(" %d-bit", GetKernelBitness()));
  }

  return strKernel;
#endif
}
Example #2
-1
CStdString CSysInfo::GetKernelVersion()
{
#if defined(TARGET_DARWIN)
  return g_sysinfo.GetUnameVersion();
#elif defined (TARGET_POSIX)
  struct utsname un;
  if (uname(&un)==0)
  {
    CStdString strKernel;
    strKernel.Format("%s %s %s %s", un.sysname, un.release, un.version, un.machine);
    return strKernel;
  }

  return "";
#else
  OSVERSIONINFOEX osvi;
  ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  osvi.dwOSVersionInfoSize = sizeof(osvi);

  std::string strKernel = "Windows";
  if (GetVersionEx((OSVERSIONINFO *)&osvi))
  {
    switch (GetWindowsVersion())
    {
    case WindowsVersionWinXP:
      if (GetSystemMetrics(SM_SERVERR2))
        strKernel.append(" Server 2003 R2");
      else if (osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER)
        strKernel.append(" Storage Server 2003");
      else if (osvi.wSuiteMask & VER_SUITE_WH_SERVER)
        strKernel.append(" Home Server");
      else if (osvi.wProductType == VER_NT_WORKSTATION && IsOS64bit())
        strKernel.append(" XP Professional");
      else if (osvi.wProductType != VER_NT_WORKSTATION)
        strKernel.append(" Server 2003");
      else if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
        strKernel.append("XP Home Edition" );
      else
        strKernel.append("XP Professional" );
      break;
    case WindowsVersionVista:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" Vista");
      else
        strKernel.append(" Server 2008");
      break;
    case WindowsVersionWin7:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" 7");
      else
        strKernel.append(" Server 2008 R2");
      break;
    case WindowsVersionWin8:
      if (osvi.wProductType == VER_NT_WORKSTATION)
        strKernel.append(" 8");
      else
        strKernel.append(" Server 2012");
      break;
    case WindowsVersionFuture:
      strKernel.append(" Unknown Future Version");
      break;
    default:
      strKernel.append(" Unknown version");
      break;
    }

    // Append Service Pack version if any
    if (osvi.wServicePackMajor > 0)
    {
      strKernel.append(StringUtils::Format(" SP%d", osvi.wServicePackMajor));
      if (osvi.wServicePackMinor > 0)
      {
        strKernel.append(StringUtils::Format(".%d", osvi.wServicePackMinor));
      }
    }

    if (IsOS64bit())
      strKernel.append(" 64-bit");
    else
      strKernel.append(" 32-bit");

    strKernel.append(StringUtils::Format(", build %d", osvi.dwBuildNumber));
  }
  else
  {
    strKernel.append(" unknown");
    if (IsOS64bit())
      strKernel.append(" 64-bit");
    else
      strKernel.append(" 32-bit");
  }

  return strKernel;
#endif
}