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