本文整理汇总了C++中CSysInfo类的典型用法代码示例。如果您正苦于以下问题:C++ CSysInfo类的具体用法?C++ CSysInfo怎么用?C++ CSysInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSysInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_Crypt
CSSD::CSSD(SSD ssd, CRYPTTYPE crypt, BOOL inSysInfo) : m_Crypt(crypt), m_ssd(ssd)
{
m_ssd.m_szProduct = GetProductInfo();
m_inSysInfo = inSysInfo;
if (m_inSysInfo) {
CSysInfo si;
m_ssd.m_szSysInfo = si.GetSysInfo();
}
}
示例2: _tmain
int _tmain(int argc, TCHAR* argv[])
{
CSysInfo sysinfo;
_tprintf_s(_T("%s 's version: "), sysinfo.GetModuleName().c_str());
_tprintf_s(_T("%s,cc:"), sysinfo.GetAppVersionInfo().FileVersion.c_str());
_tprintf_s(_T("%s"), sysinfo.GetAppVersionInfo().CompanyName.c_str());
getchar();
return 0;
}
示例3: GetHddSpaceInfo
std::string CSysInfo::GetHddSpaceInfo(int& percent, int drive, bool shortText)
{
int total, totalFree, totalUsed, percentFree, percentused;
std::string strRet;
percent = 0;
if (g_sysinfo.GetDiskSpace("", total, totalFree, totalUsed, percentFree, percentused))
{
if (shortText)
{
switch(drive)
{
case SYSTEM_FREE_SPACE:
percent = percentFree;
break;
case SYSTEM_USED_SPACE:
percent = percentused;
break;
}
}
else
{
switch(drive)
{
case SYSTEM_FREE_SPACE:
strRet = StringUtils::Format("%i MB %s", totalFree, g_localizeStrings.Get(160).c_str());
break;
case SYSTEM_USED_SPACE:
strRet = StringUtils::Format("%i MB %s", totalUsed, g_localizeStrings.Get(20162).c_str());
break;
case SYSTEM_TOTAL_SPACE:
strRet = StringUtils::Format("%i MB %s", total, g_localizeStrings.Get(20161).c_str());
break;
case SYSTEM_FREE_SPACE_PERCENT:
strRet = StringUtils::Format("%i %% %s", percentFree, g_localizeStrings.Get(160).c_str());
break;
case SYSTEM_USED_SPACE_PERCENT:
strRet = StringUtils::Format("%i %% %s", percentused, g_localizeStrings.Get(20162).c_str());
break;
}
}
}
else
{
if (shortText)
strRet = "N/A";
else
strRet = g_localizeStrings.Get(161);
}
return strRet;
}
示例4: GetSystemUpTime
std::string CSysInfoJob::GetSystemUpTime(bool bTotalUptime)
{
std::string strSystemUptime;
int iInputMinutes, iMinutes,iHours,iDays;
if(bTotalUptime)
{
//Total Uptime
iInputMinutes = g_sysinfo.GetTotalUptime() + ((int)(XbmcThreads::SystemClockMillis() / 60000));
}
else
{
//Current UpTime
iInputMinutes = (int)(XbmcThreads::SystemClockMillis() / 60000);
}
SystemUpTime(iInputMinutes,iMinutes, iHours, iDays);
if (iDays > 0)
{
strSystemUptime = StringUtils::Format("%i %s, %i %s, %i %s",
iDays, g_localizeStrings.Get(12393).c_str(),
iHours, g_localizeStrings.Get(12392).c_str(),
iMinutes, g_localizeStrings.Get(12391).c_str());
}
else if (iDays == 0 && iHours >= 1 )
{
strSystemUptime = StringUtils::Format("%i %s, %i %s",
iHours, g_localizeStrings.Get(12392).c_str(),
iMinutes, g_localizeStrings.Get(12391).c_str());
}
else if (iDays == 0 && iHours == 0 && iMinutes >= 0)
{
strSystemUptime = StringUtils::Format("%i %s",
iMinutes, g_localizeStrings.Get(12391).c_str());
}
return strSystemUptime;
}
示例5: GetHddSpaceInfo
CStdString CSysInfo::GetHddSpaceInfo(int& percent, int drive, bool shortText)
{
int total, totalFree, totalUsed, percentFree, percentused;
CStdString strDrive;
bool bRet=false;
percent = 0;
CStdString strRet;
switch (drive)
{
case SYSTEM_FREE_SPACE:
case SYSTEM_USED_SPACE:
case SYSTEM_TOTAL_SPACE:
case SYSTEM_FREE_SPACE_PERCENT:
case SYSTEM_USED_SPACE_PERCENT:
bRet = g_sysinfo.GetDiskSpace("",total, totalFree, totalUsed, percentFree, percentused);
break;
case LCD_FREE_SPACE_C:
case SYSTEM_FREE_SPACE_C:
case SYSTEM_USED_SPACE_C:
case SYSTEM_TOTAL_SPACE_C:
case SYSTEM_FREE_SPACE_PERCENT_C:
case SYSTEM_USED_SPACE_PERCENT_C:
strDrive = "C";
bRet = g_sysinfo.GetDiskSpace("C",total, totalFree, totalUsed, percentFree, percentused);
break;
case LCD_FREE_SPACE_E:
case SYSTEM_FREE_SPACE_E:
case SYSTEM_USED_SPACE_E:
case SYSTEM_TOTAL_SPACE_E:
case SYSTEM_FREE_SPACE_PERCENT_E:
case SYSTEM_USED_SPACE_PERCENT_E:
strDrive = "E";
bRet = g_sysinfo.GetDiskSpace("E",total, totalFree, totalUsed, percentFree, percentused);
break;
case LCD_FREE_SPACE_F:
case SYSTEM_FREE_SPACE_F:
case SYSTEM_USED_SPACE_F:
case SYSTEM_TOTAL_SPACE_F:
case SYSTEM_FREE_SPACE_PERCENT_F:
case SYSTEM_USED_SPACE_PERCENT_F:
strDrive = "F";
bRet = g_sysinfo.GetDiskSpace("F",total, totalFree, totalUsed, percentFree, percentused);
break;
case LCD_FREE_SPACE_G:
case SYSTEM_FREE_SPACE_G:
case SYSTEM_USED_SPACE_G:
case SYSTEM_TOTAL_SPACE_G:
case SYSTEM_FREE_SPACE_PERCENT_G:
case SYSTEM_USED_SPACE_PERCENT_G:
strDrive = "G";
bRet = g_sysinfo.GetDiskSpace("G",total, totalFree, totalUsed, percentFree, percentused);
break;
case SYSTEM_USED_SPACE_X:
case SYSTEM_FREE_SPACE_X:
case SYSTEM_TOTAL_SPACE_X:
strDrive = "X";
bRet = g_sysinfo.GetDiskSpace("X",total, totalFree, totalUsed, percentFree, percentused);
break;
case SYSTEM_USED_SPACE_Y:
case SYSTEM_FREE_SPACE_Y:
case SYSTEM_TOTAL_SPACE_Y:
strDrive = "Y";
bRet = g_sysinfo.GetDiskSpace("Y",total, totalFree, totalUsed, percentFree, percentused);
break;
case SYSTEM_USED_SPACE_Z:
case SYSTEM_FREE_SPACE_Z:
case SYSTEM_TOTAL_SPACE_Z:
strDrive = "Z";
bRet = g_sysinfo.GetDiskSpace("Z",total, totalFree, totalUsed, percentFree, percentused);
break;
}
if (bRet)
{
if (shortText)
{
switch(drive)
{
case LCD_FREE_SPACE_C:
case LCD_FREE_SPACE_E:
case LCD_FREE_SPACE_F:
case LCD_FREE_SPACE_G:
strRet.Format("%iMB", totalFree);
break;
case SYSTEM_FREE_SPACE:
case SYSTEM_FREE_SPACE_C:
case SYSTEM_FREE_SPACE_E:
case SYSTEM_FREE_SPACE_F:
case SYSTEM_FREE_SPACE_G:
case SYSTEM_FREE_SPACE_X:
case SYSTEM_FREE_SPACE_Y:
case SYSTEM_FREE_SPACE_Z:
percent = percentFree;
break;
case SYSTEM_USED_SPACE:
case SYSTEM_USED_SPACE_C:
case SYSTEM_USED_SPACE_E:
case SYSTEM_USED_SPACE_F:
case SYSTEM_USED_SPACE_G:
case SYSTEM_USED_SPACE_X:
case SYSTEM_USED_SPACE_Y:
//.........这里部分代码省略.........
示例6: 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
}
示例7: 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
}