• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ FormatBytes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FormatBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ FormatBytes函数的具体用法?C++ FormatBytes怎么用?C++ FormatBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FormatBytes函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: UNREFERENCED_PARAMETER

LRESULT Cwinproc::OnTaskbarNotify(WPARAM wParam, LPARAM lParam) {
	UNREFERENCED_PARAMETER(wParam);
	
	switch (lParam) {
		case WM_MOUSEMOVE:
		{
			CString s, sRecvBPS, sRecvAVE;
			FormatBytes(RecvStats[0].Bps, sRecvBPS, true);
			FormatBytes(RecvStats[0].ave, sRecvAVE, true);
			s.Format("Current: %s   Average: %s", sRecvBPS, sRecvAVE);
			
			m_SystemTray.cbSize = sizeof(NOTIFYICONDATA);
			m_SystemTray.hWnd   = GetSafeHwnd();
			m_SystemTray.uID    = 1;
			m_SystemTray.uFlags = NIF_TIP;
			strcpy_s(m_SystemTray.szTip, s);
			Shell_NotifyIcon(NIM_MODIFY, &m_SystemTray);
		}
		break;
		
		case WM_LBUTTONDBLCLK:
			ShowPropertiesDlg();
			break;
			
		case WM_RBUTTONUP:
		{
			CMenu menu;
			POINT pt;
			
			GetCursorPos(&pt);
			
			menu.LoadMenu(IDR_MENU1);
			menu.SetDefaultItem(0, TRUE);
			
			CMenu &pMenu = *menu.GetSubMenu(0);
			pMenu.SetDefaultItem(0, TRUE);
			
			// See Q135788 "PRB: Menus for Notification Icons Do Not Work Correctly"
			SetForegroundWindow();
			int cmd = pMenu.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, pt.x, pt.y, this);
			PostMessage(WM_NULL, 0, 0);
			
			if (cmd == IDCLOSE) {
				// Save any settings if the user closes the tray icon while the dialog is open
				if (m_pPropertiesDlg != NULL) {
					SaveSettings();
					m_pPropertiesDlg->SendMessage(WM_CLOSE);
				}
				theApp.m_wnd.PostMessage(WM_CLOSE);
			} else if (cmd == ID_PROPERTIES)
				ShowPropertiesDlg();
		}
		break;
	}
	return 0;
}
开发者ID:nayuki,项目名称:NetPerSec,代码行数:56,代码来源:winproc.cpp


示例2: CheckExtension

void ParticleInstancingRenderer::Initialize() {

    // Initialize can be called at any time - don't actually initialize
    // more than once.
    if (is_initialized)
        return;

    is_initialized = true;
    extensions_supported = false;

    // check for the extensions that are required
    GLboolean shader4_supported = CheckExtension("GL_EXT_gpu_shader4");
    if (shader4_supported)
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_gpu_shader4 supported" << endl;
    else
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_gpu_shader4 not supported" << endl;

	
    GLboolean tbo_supported = CheckExtension("GL_EXT_texture_buffer_object");
    if (tbo_supported)
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_texture_buffer_object supported" << endl;
    else
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_texture_buffer_object not supported" << endl;


    extensions_supported = (shader4_supported && tbo_supported);
	if (extensions_supported) {
	    debug1 << "ParticleInstancingRenderer: Necessary extensions supported, "
               << "using the new Molecule plot implementation." << endl;
	}
	else
    {
	    debug1 << "ParticleInstancingRenderer: Necessary extensions not supported, "
               << "using the old Molecule plot implementation." << endl;
	}

    // don't do any more if the extensions aren't supported
    if (!extensions_supported)
        return;



    // 
    GLint max_texture_buffer_size;
    glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE_EXT, &max_texture_buffer_size);
    debug1 << "maximal texture buffer size " << FormatBytes(max_texture_buffer_size) << endl;

    size_t instances_position_radius = size_t(max_texture_buffer_size) / (4*sizeof(float));
    size_t instances_color  = size_t(max_texture_buffer_size) / (4*sizeof(unsigned char));
    instanced_batch_size = std::min(instances_position_radius, instances_color);


    debug1 << "ParticleInstancingRenderer: Max number of instances " 
           << instanced_batch_size << " = "
           << instanced_batch_size / 1000000.0f << " million" << endl;

    GenerateAndBuildTBO();
    BuildSphereGeometryVBOs();
    BuildShaders();
}
开发者ID:alvarodlg,项目名称:lotsofcoresbook2code,代码行数:60,代码来源:ParticleInstancingRenderer.C


示例3: peerAddrDetails

void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
{
    // Update cached nodeid
    cachedNodeid = stats->nodeStats.nodeid;

    // update the detail ui with latest node information
    QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
    peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
    if (!stats->nodeStats.addrLocal.empty())
        peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
    ui->peerHeading->setText(peerAddrDetails);
    ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices));
    ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastSend) : tr("never"));
    ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastRecv) : tr("never"));
    ui->peerBytesSent->setText(FormatBytes(stats->nodeStats.nSendBytes));
    ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes));
    ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nTimeConnected));
    ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
    ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
    ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
    ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion)));
    ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
    ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
    ui->peerHeight->setText(QString("%1").arg(QString::number(stats->nodeStats.nStartingHeight)));
    ui->peerWhitelisted->setText(stats->nodeStats.fWhitelisted ? tr("Yes") : tr("No"));

    // This check fails for example if the lock was busy and
    // nodeStateStats couldn't be fetched.
    if (stats->fNodeStateStatsAvailable) {
        // Ban score is init to 0
        ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.nMisbehavior));

        // Sync height is init to -1
        if (stats->nodeStateStats.nSyncHeight > -1)
            ui->peerSyncHeight->setText(QString("%1").arg(stats->nodeStateStats.nSyncHeight));
        else
            ui->peerSyncHeight->setText(tr("Unknown"));

        // Common height is init to -1
        if (stats->nodeStateStats.nCommonHeight > -1)
            ui->peerCommonHeight->setText(QString("%1").arg(stats->nodeStateStats.nCommonHeight));
        else
            ui->peerCommonHeight->setText(tr("Unknown"));
    }

    ui->detailWidget->show();
}
开发者ID:recalibrate,项目名称:bitcoin,代码行数:47,代码来源:rpcconsole.cpp


示例4: tr

void RPCConsole::updateNodeDetail(const CNodeCombinedStats *combinedStats)
{
    CNodeStats stats = combinedStats->nodestats;

    // keep a copy of timestamps, used to display dates upon disconnect
    detailNodeStats.nodestats.nLastSend = stats.nLastSend;
    detailNodeStats.nodestats.nLastRecv = stats.nLastRecv;
    detailNodeStats.nodestats.nTimeConnected = stats.nTimeConnected;

    // update the detail ui with latest node information
    ui->peerHeading->setText(QString("<b>%1</b>").arg(tr("Node Detail")));
    ui->peerAddr->setText(QString(stats.addrName.c_str()));
    ui->peerServices->setText(GUIUtil::formatServicesStr(stats.nServices));
    ui->peerLastSend->setText(stats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats.nLastSend) : tr("never"));
    ui->peerLastRecv->setText(stats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats.nLastRecv) : tr("never"));
    ui->peerBytesSent->setText(FormatBytes(stats.nSendBytes));
    ui->peerBytesRecv->setText(FormatBytes(stats.nRecvBytes));
    ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats.nTimeConnected));
    ui->peerPingTime->setText(stats.dPingTime == 0 ? tr("N/A") : QString(tr("%1 secs")).arg(QString::number(stats.dPingTime, 'f', 3)));
    ui->peerVersion->setText(QString("%1").arg(stats.nVersion));
    ui->peerSubversion->setText(QString(stats.cleanSubVer.c_str()));
    ui->peerDirection->setText(stats.fInbound ? tr("Inbound") : tr("Outbound"));
    ui->peerHeight->setText(QString("%1").arg(stats.nStartingHeight));
    ui->peerSyncNode->setText(stats.fSyncNode ? tr("Yes") : tr("No"));

    // if we can, display the peer's ban score
    CNodeStateStats statestats = combinedStats->statestats;
    if (statestats.nMisbehavior >= 0)
    {
        // we have a new nMisbehavor value - update the cache
        detailNodeStats.statestats.nMisbehavior = statestats.nMisbehavior;
    }

    // pull the ban score from cache.  -1 means it hasn't been retrieved yet (lock busy).
    if (detailNodeStats.statestats.nMisbehavior >= 0)
        ui->peerBanScore->setText(QString("%1").arg(detailNodeStats.statestats.nMisbehavior));
    else
        ui->peerBanScore->setText(tr("Fetching..."));
}
开发者ID:KaSt,项目名称:ekwicoin,代码行数:39,代码来源:rpcconsole.cpp


示例5: switch

CString CDriveItem::GetText(int subitem) const
{
	CString s;

	switch (subitem)
	{
	case COL_NAME:
		s= m_name;
		break;

	case COL_TOTAL:
		if (m_success)
			s= FormatBytes((LONGLONG)m_totalBytes);
		break;

	case COL_FREE:
		if (m_success)
			s= FormatBytes((LONGLONG)m_freeBytes);
		break;

	case COL_GRAPH:
		if (m_querying)
			s.LoadString(IDS_QUERYING);
		else if (!m_success)
			s.LoadString(IDS_NOTACCESSIBLE);
		break;

	case COL_PERCENTUSED:
		if (m_success)
			s= FormatDouble(m_used * 100) + _T("%");
		break;

	default:
		ASSERT(0);
	}
	
	return s;
}
开发者ID:coapp-packages,项目名称:windirstat,代码行数:38,代码来源:SelectDrivesDlg.cpp


示例6: UpdateMemoryInfo

CString CDirstatApp::GetCurrentProcessMemoryInfo()
{
	UpdateMemoryInfo();

	if (m_workingSet == 0)
		return _T("");

	CString n= PadWidthBlanks(FormatBytes(m_workingSet), 11);

	CString s;
	s.FormatMessage(IDS_RAMUSAGEs, n);

	return s;
}
开发者ID:coapp-packages,项目名称:windirstat,代码行数:14,代码来源:windirstat.cpp


示例7: switch

CString CExtensionListControl::CListItem::GetText(int subitem) const
{
    switch (subitem)
    {
    case COL_EXTENSION:
        {
            return GetExtension();
        }

    case COL_COLOR:
        {
            return _T("(color)");
        }

    case COL_BYTES:
        {
            return FormatBytes(m_record.bytes);
        }

    case COL_FILES:
        {
            return FormatCount(m_record.files);
        }

    case COL_DESCRIPTION:
        {
            return GetDescription();
        }

    case COL_BYTESPERCENT:
        {
            return GetBytesPercent();
        }

    default:
        {
            ASSERT(0);
            return wds::strEmpty;
        }
    }
}
开发者ID:JDuverge,项目名称:windirstat,代码行数:41,代码来源:typeview.cpp


示例8: FormatBytes

void ParticleInstancingRenderer::BuildTBO(const GLuint tbo, const GLuint tex, size_t tbo_size,  \
                                          GLenum usage, GLenum internal_format)
{
    debug1 << "\tbuilding texture buffer for instance data of size " << FormatBytes(tbo_size) << endl;

    glBindBufferARB(GL_TEXTURE_BUFFER_ARB, tbo);
    CheckOpenGLError();

    glBufferDataARB(GL_TEXTURE_BUFFER_ARB, tbo_size, 0, usage);
    CheckOpenGLError();

    glBindTexture(GL_TEXTURE_BUFFER_ARB, tex );
    CheckOpenGLError();

    glTexBufferARB(GL_TEXTURE_BUFFER_ARB, internal_format, tbo);
    CheckOpenGLError();

    // clear texture / bufer bindings
    glBindBufferARB(GL_TEXTURE_BUFFER_ARB, 0);
    CheckOpenGLError();
    glBindTexture(GL_TEXTURE_BUFFER_ARB, 0);
    CheckOpenGLError();
}
开发者ID:alvarodlg,项目名称:lotsofcoresbook2code,代码行数:23,代码来源:ParticleInstancingRenderer.C


示例9: SetDlgItemText

void CHomeUI::OnDeviceInfo(PE_DEV_INFO *pInfo)
{
	CString sPhone;
	sPhone.Format(_T("Phone: %s, made by %s"),pInfo->szPhoneModel,pInfo->szPhoneManufacturer);
	SetDlgItemText(IDC_STATIC_PHONE_NAME,sPhone);

	CString sSDCard;
	CString sTotal = FormatBytes(pInfo->dwSDCardTotalSpace);
	float fPercent = 0;
	if (pInfo->dwSDCardTotalSpace)
	{
		fPercent = (float)((double)pInfo->dwSDCardAvailableSpace/(double)pInfo->dwSDCardTotalSpace);
		fPercent *= 100;
	}
	sSDCard.Format(_T("SDCard: total %s(%d%% free)"),sTotal.GetBuffer(),(int)fPercent);
	sTotal.ReleaseBuffer();
	m_progSdCard.SetWindowText(sSDCard);
	m_progSdCard.SetPos((int)fPercent);

	CString sPercent;
	sPercent.Format(_T("Battery:%d%% remaining"),pInfo->dwBatteryLevel);
	m_batteryLevel.SetWindowText(sPercent);
	m_batteryLevel.SetPos((int)pInfo->dwBatteryLevel);
}
开发者ID:HamiguaLu,项目名称:YaSync,代码行数:24,代码来源:HomeUI.cpp


示例10: updateTrafficStats

void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
{
    ui->lblBytesIn->setText(FormatBytes(totalBytesIn));
    ui->lblBytesOut->setText(FormatBytes(totalBytesOut));
}
开发者ID:BoodleKing,项目名称:Boodle,代码行数:5,代码来源:rpcconsole.cpp


示例11: DebugAssert

//---------------------------------------------------------------------------
void __fastcall TQueueController::FillQueueViewItem(TListItem * Item,
  TQueueItemProxy * QueueItem, bool Detail)
{
  DebugAssert(!Detail || (QueueItem->Status != TQueueItem::qsPending));

  DebugAssert((Item->Data == NULL) || (Item->Data == QueueItem));
  Item->Data = QueueItem;

  UnicodeString ProgressStr;
  int Image = -1;

  switch (QueueItem->Status)
  {
    case TQueueItem::qsDone:
      ProgressStr = LoadStr(QUEUE_DONE);
      break;

    case TQueueItem::qsPending:
      ProgressStr = LoadStr(QUEUE_PENDING);
      break;

    case TQueueItem::qsConnecting:
      ProgressStr = LoadStr(QUEUE_CONNECTING);
      break;

    case TQueueItem::qsQuery:
      ProgressStr = LoadStr(QUEUE_QUERY);
      Image = 4;
      break;

    case TQueueItem::qsError:
      ProgressStr = LoadStr(QUEUE_ERROR);
      Image = 5;
      break;

    case TQueueItem::qsPrompt:
      ProgressStr = LoadStr(QUEUE_PROMPT);
      Image = 6;
      break;

    case TQueueItem::qsPaused:
      ProgressStr = LoadStr(QUEUE_PAUSED);
      Image = 7;
      break;
  }

  bool BlinkHide = QueueItemNeedsFrequentRefresh(QueueItem) &&
    !QueueItem->ProcessingUserAction &&
    ((GetTickCount() % MSecsPerSec) >= (MSecsPerSec/2));

  int State = -1;
  UnicodeString Values[6];
  TFileOperationProgressType * ProgressData = QueueItem->ProgressData;
  TQueueItem::TInfo * Info = QueueItem->Info;

  if (!Detail)
  {
    switch (Info->Operation)
    {
      case foCopy:
        State = ((Info->Side == osLocal) ? 2 : 0);
        break;

      case foMove:
        State = ((Info->Side == osLocal) ? 3 : 1);
        break;
    }

    // cannot use ProgressData->Temp as it is set only after the transfer actually starts
    Values[0] = Info->Source.IsEmpty() ? LoadStr(PROGRESS_TEMP_DIR) : Info->Source;
    Values[1] = Info->Destination.IsEmpty() ? LoadStr(PROGRESS_TEMP_DIR) : Info->Destination;

    __int64 TotalTransferred = QueueItem->TotalTransferred;
    if (TotalTransferred >= 0)
    {
      Values[2] =
        FormatPanelBytes(TotalTransferred, WinConfiguration->FormatSizeBytes);
    }

    if (ProgressData != NULL)
    {
      if (ProgressData->Operation == Info->Operation)
      {
        if (QueueItem->Status != TQueueItem::qsDone)
        {
          if (ProgressData->TotalSizeSet)
          {
            Values[3] = FormatDateTimeSpan(Configuration->TimeFormat, ProgressData->TotalTimeLeft());
          }
          else
          {
            Values[3] = FormatDateTimeSpan(Configuration->TimeFormat, ProgressData->TimeElapsed());
          }

          Values[4] = FORMAT(L"%s/s", (FormatBytes(ProgressData->CPS())));
        }

        if (ProgressStr.IsEmpty())
        {
//.........这里部分代码省略.........
开发者ID:anyue100,项目名称:winscp,代码行数:101,代码来源:QueueController.cpp


示例12: SetDlgItemBytes

void SetDlgItemBytes (HWND hDlg, int idc, double lfValue)
{
   TCHAR szText[ 256 ];
   FormatBytes (szText, lfValue);
   SetDlgItemText (hDlg, idc, szText);
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:6,代码来源:tal_alloc.cpp


示例13: MemMgr_OnListAdd

void MemMgr_OnListAdd (PMEMCHUNK pCopy)
{
   HWND hList = GetDlgItem (l.hManager, IDC_LIST);

   TCHAR szTime[256];
   FormatTime (szTime, pCopy->dwTick);

   TCHAR szFlags[256];
   LPTSTR pszFlags = szFlags;
   *pszFlags++ = (pCopy->fCPP) ? TEXT('C') : TEXT(' ');
   *pszFlags++ = TEXT(' ');
   *pszFlags++ = (pCopy->fFreed) ? TEXT('F') : TEXT(' ');
   *pszFlags++ = 0;

   TCHAR szExpr[256];
   lstrcpy (szExpr, (pCopy->pszExpr) ? pCopy->pszExpr : TEXT("unknown"));

   LPTSTR pszFile = pCopy->pszFile;
   for (LPTSTR psz = pCopy->pszFile; *psz; ++psz)
      {
      if ((*psz == TEXT(':')) || (*psz == TEXT('\\')))
         pszFile = &psz[1];
      }
   TCHAR szLocation[256];
   if (!pszFile || !pCopy->dwLine)
      lstrcpy (szLocation, TEXT("unknown"));
   else
      wsprintf (szLocation, TEXT("%s, %ld"), pszFile, pCopy->dwLine);

   TCHAR szBytes[256];
   FormatBytes (szBytes, (double)pCopy->cbData);

   TCHAR szAddress[256];
   wsprintf (szAddress, TEXT("0x%08p"), pCopy->pData);

   LPTSTR pszKey = NULL;
   switch (lr.iColSort)
      {
      case 0:  pszKey = (LPTSTR)UlongToPtr(pCopy->dwTick);  break;
      case 1:  pszKey = (LPTSTR)szFlags;        break;
      case 2:  pszKey = (LPTSTR)szExpr;         break;
      case 3:  pszKey = (LPTSTR)szLocation;     break;
      case 4:  pszKey = (LPTSTR)pCopy->cbData;  break;
      case 5:  pszKey = (LPTSTR)pCopy->pData;   break;
      }

   LV_ITEM Item;
   memset (&Item, 0x00, sizeof(Item));
   Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
   Item.iItem = MemMgr_PickListInsertionPoint (hList, pszKey);
   Item.iSubItem = 0;
   Item.cchTextMax = 256;
   Item.lParam = (LPARAM)pCopy->pData;

   Item.pszText = szTime;
   DWORD iItem = ListView_InsertItem (hList, &Item);
   ListView_SetItemText (hList, iItem, 1, szFlags);
   ListView_SetItemText (hList, iItem, 2, szExpr);
   ListView_SetItemText (hList, iItem, 3, szLocation);
   ListView_SetItemText (hList, iItem, 4, szBytes);
   ListView_SetItemText (hList, iItem, 5, szAddress);

   delete pCopy;
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:64,代码来源:tal_alloc.cpp


示例14: ASSERT

BOOL CHwSMTP::SendOnAttach(LPCTSTR lpszFileName)
{
	ASSERT ( lpszFileName );
	CString csAttach, csTemp;

	csTemp = lpszFileName;
	CString csShortFileName = csTemp.GetBuffer(0) + csTemp.ReverseFind ( '\\' );
	csShortFileName.TrimLeft ( _T("\\") );

	csTemp.Format ( _T("--%s\r\n"), m_csPartBoundary );
	csAttach += csTemp;

	csTemp.Format ( _T("Content-Type: application/octet-stream; file=%s\r\n"), csShortFileName );
	csAttach += csTemp;

	csTemp.Format ( _T("Content-Transfer-Encoding: base64\r\n") );
	csAttach += csTemp;

	csTemp.Format ( _T("Content-Disposition: attachment; filename=%s\r\n\r\n"), csShortFileName );
	csAttach += csTemp;

	DWORD dwFileSize =  hwGetFileAttr(lpszFileName);
	if ( dwFileSize > 5*1024*1024 )
	{
		m_csLastError.Format ( _T("File [%s] too big. File size is : %s"), lpszFileName, FormatBytes(dwFileSize) );
		return FALSE;
	}
	char *pBuf = new char[dwFileSize+1];
	if ( !pBuf )
	{
		::AfxThrowMemoryException ();
		return FALSE;
	}

	if(!Send ( csAttach ))
	{
		delete[] pBuf;
		return FALSE;
	}

	CFile file;
	CStringA filedata;
	try
	{
		if ( !file.Open ( lpszFileName, CFile::modeRead ) )
		{
			m_csLastError.Format ( _T("Open file [%s] failed"), lpszFileName );			
			delete[] pBuf;
			return FALSE;
		}
		UINT nFileLen = file.Read ( pBuf, dwFileSize );
		CBase64 Base64Encode;
		filedata = Base64Encode.Encode ( pBuf, nFileLen );
		filedata += _T("\r\n\r\n");
	}
	catch (CFileException *e)
	{
		e->Delete();
		m_csLastError.Format ( _T("Read file [%s] failed"), lpszFileName );
		delete[] pBuf;
		return FALSE;
	}

	if(!SendBuffer( filedata.GetBuffer() ))
	{
		delete[] pBuf;
		return FALSE;
	}

	delete[] pBuf;

	return TRUE;
	//return Send ( csAttach );
}
开发者ID:chengn,项目名称:TortoiseGit,代码行数:74,代码来源:HwSMTP.cpp


示例15: switch

CString CItem::GetText(int subitem) const
{
	CString s;
	switch (subitem)
	{
	case COL_NAME:
		s = m_name;
		break;

	case COL_SUBTREEPERCENTAGE:
		if (IsDone())
		{
			ASSERT(m_readJobs == 0);
			//s = "ok";
		}
		else
		{
			if (m_readJobs == 1)
				s.LoadString(IDS_ONEREADJOB);
			else
				s.FormatMessage(IDS_sREADJOBS, FormatCount(m_readJobs));
		}
		break;

	case COL_PERCENTAGE:
		if (GetOptions()->IsShowTimeSpent() && MustShowReadJobs() || IsRootItem())
		{
			s.Format(_T("[%s s]"), FormatMilliseconds(GetTicksWorked()));
		}
		else
		{
			s.Format(_T("%s%%"), FormatDouble(GetFraction() * 100));
		}
		break;

	case COL_SUBTREETOTAL:
		s = FormatBytes(GetSize());
		break;

	case COL_ITEMS:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetItemsCount());
		break;

	case COL_FILES:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetFilesCount());
		break;

	case COL_SUBDIRS:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetSubdirsCount());
		break;

	case COL_LASTCHANGE:
		if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
		{
			s = FormatFileTime(m_lastChange);
		}
		break;

	case COL_ATTRIBUTES:
		if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN && GetType() != IT_MYCOMPUTER && GetType() != IT_FILESFOLDER)
		{
			s = FormatAttributes(GetAttributes());
		}
		break;

	default:
		ASSERT(0);
		break;
	}
	return s;
}
开发者ID:coapp-packages,项目名称:windirstat,代码行数:74,代码来源:item.cpp


示例16: FormatBytes

std::string FormatBytes(u64 numBytes)
{
	return FormatBytes((double)numBytes);
}
开发者ID:edwardt,项目名称:kNet,代码行数:4,代码来源:Network.cpp


示例17: _Success_

//COLORREF CDirstatApp::AltEncryptionColor( ) {
//	return m_altEncryptionColor;
//	}

_Success_( SUCCEEDED( return ) ) HRESULT CDirstatApp::GetCurrentProcessMemoryInfo( _Out_writes_z_( strSize ) PWSTR psz_formatted_usage, _In_range_( 20, 64 ) rsize_t strSize ) {
	auto workingSetBefore = m_workingSet;
	UpdateMemoryInfo( );
	const rsize_t ramUsageBytesStrBufferSize = 21;
	wchar_t ramUsageBytesStrBuffer[ ramUsageBytesStrBufferSize ] = { 0 };

	//const rsize_t strSize = 34;
	//wchar_t psz_formatted_usage[ strSize ] = { 0 };


	HRESULT res = FormatBytes( m_workingSet, ramUsageBytesStrBuffer, ramUsageBytesStrBufferSize );
	if ( !SUCCEEDED( res ) ) {
		return StringCchPrintfW( psz_formatted_usage, strSize, L"RAM Usage: %s", FormatBytes( m_workingSet ).GetString( ) );
		}


	HRESULT res2 = StringCchPrintfW( psz_formatted_usage, strSize, L"RAM Usage: %s", ramUsageBytesStrBuffer );
	if ( !SUCCEEDED( res2 ) ) {
		CString n = ( _T( "RAM Usage: %s" ), ramUsageBytesStrBuffer );
		auto buf = n.GetBuffer( strSize );
		HRESULT res3 = StringCchCopy( psz_formatted_usage, strSize, buf );
		return res3;
		}

	return res2;
	}
开发者ID:AKKF,项目名称:altWinDirStat,代码行数:30,代码来源:windirstat.cpp


示例18: main


//.........这里部分代码省略.........
    base::RegKey reg(HKEY_CURRENT_USER, L"Environment", KEY_QUERY_VALUE);
    std::wstring reg_temp;
    if(reg.Valid())
    {
        reg.ReadValue(L"TEMP", &reg_temp);
    }

    CoInitialize(NULL);
    base::ScopedComPtr<IDropTargetHelper, &IID_IDropTargetHelper> scomp;
    if(SUCCEEDED(scomp.CreateInstance(CLSID_DragDropHelper)))
    {
        scomp = NULL;
    }
    CoUninitialize();

    scoped_ptr<double> spd(new double(3.1));
    spd.reset();

    base::Singleton<FooClass>::get()->Bar();

    int cvt = 0;
    base::StringToInt("123", &cvt);
    std::string str_d = base::DoubleToString(2.123);

    base::StringPiece s1;
    assert(s1.length() == 0);
    assert(s1.size() == 0);
    assert(s1.data() == NULL);

    base::StringPiece s2("I love you");
    assert(s2.find('I') != base::StringPiece::npos);

    std::vector<std::string> v;
    base::SplitString("wlw&el", '&', &v);

    std::vector<std::string> subst;
    subst.push_back("10");
    subst.push_back("20");
    subst.push_back("30");
    std::string add = ReplaceStringPlaceholders("$2+$1=$3", subst, NULL);
    string16 bytes = FormatBytes(5*1024, DATA_UNITS_KIBIBYTE, true);

    std::string profile = base::StringPrintf("wlw's age is %d", 29);

    LOG(WARNING) << "This is a warning!";
    //DCHECK(1 == 0);

    base::Time::EnableHighResolutionTimer(true);
    base::Time t = base::Time::Now();
    base::Time::Exploded te;
    t.LocalExplode(&te);
    base::TimeTicks tt = base::TimeTicks::Now();
    base::TimeTicks tth = base::TimeTicks::HighResNow();

    std::string utf8 = WideToUTF8(L"wan lian wen - мРа╛нд");
    std::wstring wide = UTF8ToWide(utf8);

    DictionaryValue root;
    root.SetString("global.pages.homepage", "http://goateleporter.com");
    std::string homepage = "http://google.com";
    root.GetString("global.pages.homepage", &homepage);

    Version* ver = Version::GetVersionFromString("2.0.0.1");
    delete ver;

    base::WinVersion version = base::GetWinVersion();

    std::wstring user_sid;
    base::GetUserSidString(&user_sid);

    std::string base64;
    base::Base64Encode("I'm wlw.", &base64);
    std::string md5 = MD5String("I'm wlw.");
    std::string sha1 = base::SHA1HashString("I'm wlw.");
    std::string sha2 = base::SHA256HashString("I'm wlw.");

    std::string json = base::GetDoubleQuotedJson("a<>b;\nb = 0;");
    std::string json_write;
    base::JSONWriter::Write(&root, false, &json_write);
    Value* json_read = base::JSONReader::Read(json_write, false);
    delete json_read;

    Tuple3<int, double, bool> t3 = MakeTuple(10, 2.5, false);

    ObjClass obj;
    Callback0::Type* callback = NewCallback(&obj, &ObjClass::Bar);
    callback->Run();
    delete callback;

    thred.Start();
    thred.message_loop()->PostDelayedTask(new PrintTask(), 1000);

    MessageLoop msg_loop;
    msg_loop.PostDelayedTask(new MainThreadPrintTask(), 3000);
    msg_loop.Run();

    thred.Stop();

    return 0;
}
开发者ID:hgl888,项目名称:x-framework,代码行数:101,代码来源:main.cpp



注:本文中的FormatBytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FormatDateTime函数代码示例发布时间:2022-05-30
下一篇:
C++ Format函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap