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(); } }
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; }
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; }
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; }
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: case SYSTEM_USED_SPACE_Z: percent = percentused; break; } } else { switch(drive) { 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: if (strDrive.IsEmpty()) strRet.Format("%i MB %s", totalFree, g_localizeStrings.Get(160)); else strRet.Format("%s: %i MB %s", strDrive, totalFree, g_localizeStrings.Get(160)); 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: case SYSTEM_USED_SPACE_Z: if (strDrive.IsEmpty()) strRet.Format("%i MB %s", totalUsed, g_localizeStrings.Get(20162)); else strRet.Format("%s: %i MB %s", strDrive, totalUsed, g_localizeStrings.Get(20162)); break; case SYSTEM_TOTAL_SPACE: case SYSTEM_TOTAL_SPACE_C: case SYSTEM_TOTAL_SPACE_E: case SYSTEM_TOTAL_SPACE_F: case SYSTEM_TOTAL_SPACE_G: if (strDrive.IsEmpty()) strRet.Format("%i MB %s", total, g_localizeStrings.Get(20161)); else strRet.Format("%s: %i MB %s", strDrive, total, g_localizeStrings.Get(20161)); break; case SYSTEM_FREE_SPACE_PERCENT: case SYSTEM_FREE_SPACE_PERCENT_C: case SYSTEM_FREE_SPACE_PERCENT_E: case SYSTEM_FREE_SPACE_PERCENT_F: case SYSTEM_FREE_SPACE_PERCENT_G: if (strDrive.IsEmpty()) strRet.Format("%i %% %s", percentFree, g_localizeStrings.Get(160)); else strRet.Format("%s: %i %% %s", strDrive, percentFree, g_localizeStrings.Get(160)); break; case SYSTEM_USED_SPACE_PERCENT: case SYSTEM_USED_SPACE_PERCENT_C: case SYSTEM_USED_SPACE_PERCENT_E: case SYSTEM_USED_SPACE_PERCENT_F: case SYSTEM_USED_SPACE_PERCENT_G: if (strDrive.IsEmpty()) strRet.Format("%i %% %s", percentused, g_localizeStrings.Get(20162)); else strRet.Format("%s: %i %% %s", strDrive, percentused, g_localizeStrings.Get(20162)); break; } } } else { if (shortText) strRet = "N/A"; else if (strDrive.IsEmpty()) strRet = g_localizeStrings.Get(161); else strRet.Format("%s: %s", strDrive, g_localizeStrings.Get(161)); } return strRet; }
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 }
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 }