⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysutils.cpp

📁 一个用vc获取系统硬件信息的例子
💻 CPP
字号:
//------------------------------------------------------------------------------
// SysUtils.cpp
//    
//   This file contains SysUtils. Use this class just like a namespace 
//   for now. This class cannot be instantiated; it exists only to provide 
//   useful functions for other classes. 
// 
//   Copyright (c) 2001 Paul Wendt [p-wendt@wideopenwest.com]
#include "SysUtils.h"

#include <sstream>
using namespace std;

std::string SysUtils::ByteToStr(const __int64& n64ByteCount /* = 0 */, const int& nPrecision /* = 2 */)
{
   const int NUMFORMATTERS = 5;
   char szFormatters[NUMFORMATTERS][10] = {" bytes", " KB", " MB", " GB", " TB" };
   double dblBase = n64ByteCount;
   int nNumConversions = 0;

   while (dblBase > 1000)
	{
		dblBase /= 1024;
      nNumConversions++;
	}

   string strUnits;
   if ((0 <= nNumConversions) && (nNumConversions <= NUMFORMATTERS))
   {
      strUnits = szFormatters[nNumConversions];
   }
   
   ostringstream os;
   os.setf(ostringstream::fixed);
   os.precision(nPrecision);
   os << dblBase << strUnits << ends;
   return (os.str());   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -