本文整理汇总了C++中CSysInfo::GetUnameVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ CSysInfo::GetUnameVersion方法的具体用法?C++ CSysInfo::GetUnameVersion怎么用?C++ CSysInfo::GetUnameVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSysInfo
的用法示例。
在下文中一共展示了CSysInfo::GetUnameVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetKernelVersion
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
}
示例2: GetKernelVersion
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
}