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; }
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(); }
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(); }
static FormatARRAY8 ( ARRAY8Ptr a, char *buf, int buflen) { return FormatBytes (a->data, a->length, buf, buflen); }
//--------------------------------------------------------------------- UnicodeString __fastcall TFileSystemInfoDialog::SpaceStr(__int64 Bytes) { UnicodeString Result; if (Bytes == 0) { Result = LoadStr(FSINFO_BYTES_UNKNOWN); } else { Result = FormatBytes(Bytes); UnicodeString SizeUnorderedStr = FormatBytes(Bytes, false); if (Result != SizeUnorderedStr) { Result = FORMAT(L"%s (%s)", (Result, SizeUnorderedStr)); } } return Result; }
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...")); }
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; }
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; }
static FormatChooserArgument ( char *buf, int len) { unsigned char addr_buf[1024]; int addr_len = sizeof (addr_buf); unsigned char result_buf[1024]; int result_len = 0; int netfamily; if (GetChooserAddr (addr_buf, &addr_len) == -1) { LogError ((unsigned char *)"Cannot get return address for chooser socket\n"); Debug ("Cannot get chooser socket address\n"); return 0; } netfamily = NetaddrFamily((XdmcpNetaddr)addr_buf); switch (netfamily) { case AF_INET: { char *port; int portlen; ARRAY8Ptr localAddress, getLocalAddress (); port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen); result_buf[0] = netfamily >> 8; result_buf[1] = netfamily & 0xFF; result_buf[2] = port[0]; result_buf[3] = port[1]; localAddress = getLocalAddress (); bcopy ((char *)localAddress->data, (char *)result_buf+4, 4); result_len = 8; } break; #ifdef AF_DECnet case AF_DECnet: break; #endif default: Debug ("Chooser family %d isn't known\n", netfamily); return 0; } return FormatBytes (result_buf, result_len, buf, len); }
//--------------------------------------------------------------------------- void __fastcall TFileFindDialog::FileFound(TTerminal * /*Terminal*/, const UnicodeString FileName, const TRemoteFile * AFile, bool & Cancel) { TListItem * Item = FileView->Items->Add(); TRemoteFile * File = AFile->Duplicate(true); Item->Data = File; Item->ImageIndex = File->IconIndex; UnicodeString Caption = File->FileName; if (File->IsDirectory) { Caption = UnixIncludeTrailingBackslash(Caption); } Item->Caption = Caption; UnicodeString Directory = UnixExtractFilePath(File->FullFileName); if (AnsiSameText(FDirectory, Directory.SubString(1, FDirectory.Length()))) { Directory[1] = L'.'; Directory.Delete(2, FDirectory.Length() - 1); } else { assert(false); } Item->SubItems->Add(Directory); if (File->IsDirectory) { Item->SubItems->Add(L""); } else { Item->SubItems->Add( FormatBytes(File->Size, WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(File->Modification, File->ModificationFmt)); UpdateControls(); Cancel = (FState == ffAborting); Application->ProcessMessages(); }
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; } } }
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(); }
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); }
void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut) { ui->lblBytesIn->setText(FormatBytes(totalBytesIn)); ui->lblBytesOut->setText(FormatBytes(totalBytesOut)); }
//--------------------------------------------------------------------------- void __fastcall TSynchronizeChecklistDialog::LoadItem(TListItem * Item) { UnicodeString S; const TSynchronizeChecklist::TItem * ChecklistItem = FChecklist->Item[Item->Index]; Item->Data = const_cast<TSynchronizeChecklist::TItem *>(ChecklistItem); Item->Checked = ChecklistItem->Checked; if (ChecklistItem->ImageIndex >= 0) { Item->ImageIndex = ChecklistItem->ImageIndex; } else { Item->ImageIndex = FakeFileImageIndex(ChecklistItem->GetFileName(), FLAGMASK(ChecklistItem->IsDirectory, FILE_ATTRIBUTE_DIRECTORY)); } S = ChecklistItem->GetFileName(); if (ChecklistItem->IsDirectory) { S = IncludeTrailingBackslash(S); } Item->Caption = S; if (ChecklistItem->Action == TSynchronizeChecklist::saDeleteRemote) { Item->SubItems->Add(L""); Item->SubItems->Add(L""); Item->SubItems->Add(L""); } else { S = ChecklistItem->Local.Directory; if (AnsiSameText(FLocalDirectory, S.SubString(1, FLocalDirectory.Length()))) { S[1] = L'.'; S.Delete(2, FLocalDirectory.Length() - 1); } else { assert(false); } Item->SubItems->Add(S); if (ChecklistItem->Action == TSynchronizeChecklist::saDownloadNew) { Item->SubItems->Add(L""); Item->SubItems->Add(L""); } else { if (ChecklistItem->IsDirectory) { Item->SubItems->Add(L""); } else { Item->SubItems->Add( FormatBytes(ChecklistItem->Local.Size, WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(ChecklistItem->Local.Modification, ChecklistItem->Local.ModificationFmt)); } } Item->SubItems->Add(L""); if (ChecklistItem->Action == TSynchronizeChecklist::saDeleteLocal) { Item->SubItems->Add(L""); Item->SubItems->Add(L""); Item->SubItems->Add(L""); } else { S = ChecklistItem->Remote.Directory; if (AnsiSameText(FRemoteDirectory, S.SubString(1, FRemoteDirectory.Length()))) { S[1] = L'.'; S.Delete(2, FRemoteDirectory.Length() - 1); } else { assert(false); } Item->SubItems->Add(S); if (ChecklistItem->Action == TSynchronizeChecklist::saUploadNew) { Item->SubItems->Add(L""); Item->SubItems->Add(L""); } else { if (ChecklistItem->IsDirectory) { Item->SubItems->Add(L""); } else { Item->SubItems->Add( FormatBytes(ChecklistItem->Remote.Size, WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(ChecklistItem->Remote.Modification, ChecklistItem->Remote.ModificationFmt)); } } }
//--------------------------------------------------------------------------- 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()) { ProgressStr = FORMAT(L"%d%%", (ProgressData->OverallProgress())); } } else if (ProgressData->Operation == foCalculateSize) { ProgressStr = LoadStr(QUEUE_CALCULATING_SIZE); } } Values[5] = ProgressStr; } else { Image = -1; if (ProgressData != NULL) { if ((Info->Side == osRemote) || !ProgressData->Temp) { Values[0] = ProgressData->FileName; } else { Values[0] = ExtractFileName(ProgressData->FileName); } if (ProgressData->Operation == Info->Operation) { Values[2] = FormatPanelBytes(ProgressData->TransferedSize, WinConfiguration->FormatSizeBytes); Values[5] = FORMAT(L"%d%%", (ProgressData->TransferProgress())); } } else { Values[0] = ProgressStr; } } Item->StateIndex = (!BlinkHide ? State : -1); Item->ImageIndex = (!BlinkHide ? Image : -1); for (size_t Index = 0; Index < LENOF(Values); Index++) { if (Index < static_cast<size_t>(Item->SubItems->Count)) { Item->SubItems->Strings[Index] = Values[Index]; } else { Item->SubItems->Add(Values[Index]); } } }
void SetDlgItemBytes (HWND hDlg, int idc, double lfValue) { TCHAR szText[ 256 ]; FormatBytes (szText, lfValue); SetDlgItemText (hDlg, idc, szText); }
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; }
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 ); }
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; }
std::string FormatBytes(u64 numBytes) { return FormatBytes((double)numBytes); }
//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; }
int main() { base::AtExitManager exit_manager; base::CommandLine::Init(0, NULL); BaseInitLoggingImpl(L"debug.log", base::LOG_ONLY_TO_FILE, base::LOCK_LOG_FILE, base::DELETE_OLD_LOG_FILE); int loga = base::Log2Floor(1); base::Environment* e = base::Environment::Create(); std::string sys_path; e->GetVar("path", &sys_path); base::CPU cpu; bool finite = base::IsFinite(1.01); base::FilePath path; std::vector<std::wstring> components; path.GetComponents(&components); path.Append(L"c:"); path.Append(L"pWRD"); path.Append(L"testDir"); path.Append(L"\\wlw.txt"); path.GetComponents(&components); bool absolute = path.IsAbsolute(); base::FilePath path2(L"wlwtxt"); path2.GetComponents(&components); absolute = path2.IsAbsolute(); base::FilePath search_path(L"C:\\"); base::CountFilesCreatedAfter(search_path, base::Time::Now()); int err = base::EnsureDirectoryForFile(path, NULL); base::Delete(base::FilePath(L"c:\\pWRD"), true); FileVersionInfo* fvi = FileVersionInfo::CreateFileVersionInfoForCurrentModule(); if(fvi) { std::wstring file_ver = fvi->file_version(); delete fvi; } base::FileEnumerator file_iter(search_path, false, base::FileEnumerator::DIRECTORIES, L"3rd"); for(base::FilePath current=file_iter.Next(); !current.Empty(); current=file_iter.Next()) { std::wcout << current.value() << std::endl; base::FileEnumerator::FindInfo fi; file_iter.GetFindInfo(&fi); if(file_iter.IsDirectory(fi)) { int64 size = base::ComputeDirectorySize(current); std::wcout << L"Directory size is: " << size << std::endl; size = base::ComputeFilesSize(current, L""); std::wcout << L"Files size is: " << size << std::endl; } } Pickle p; p.WriteInt(1); p.WriteString("I'm wlw!"); p.WriteWString(L"I'm WLW!"); int p_i; std::string p_str; std::wstring p_wstr; void* iter = NULL; p.ReadInt(&iter, &p_i); p.ReadString(&iter, &p_str); p.ReadWString(&iter, &p_wstr); base::RegKey reg(HKEY_CURRENT_USER, L"Environment", KEY_QUERY_VALUE); std::wstring reg_temp; if(reg.Valid()) { reg.ReadValue(L"TEMP", ®_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; }