int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { int ret = 0; LPPROCESS_PAGE_LIST_ITEM Param1; LPPROCESS_PAGE_LIST_ITEM Param2; ULONG IndexParam1; ULONG IndexParam2; WCHAR text1[260]; WCHAR text2[260]; ULONG l1; ULONG l2; LARGE_INTEGER time1; LARGE_INTEGER time2; IO_COUNTERS iocounters1; IO_COUNTERS iocounters2; ULONGLONG ull1; ULONGLONG ull2; if (TaskManagerSettings.SortAscending) { Param1 = (LPPROCESS_PAGE_LIST_ITEM)lParam1; Param2 = (LPPROCESS_PAGE_LIST_ITEM)lParam2; } else { Param1 = (LPPROCESS_PAGE_LIST_ITEM)lParam2; Param2 = (LPPROCESS_PAGE_LIST_ITEM)lParam1; } IndexParam1 = PerfDataGetProcessIndex(Param1->ProcessId); IndexParam2 = PerfDataGetProcessIndex(Param2->ProcessId); if (TaskManagerSettings.SortColumn == COLUMN_IMAGENAME) { PerfDataGetImageName(IndexParam1, text1, sizeof (text1) / sizeof (*text1)); PerfDataGetImageName(IndexParam2, text2, sizeof (text2) / sizeof (*text2)); ret = _wcsicmp(text1, text2); } else if (TaskManagerSettings.SortColumn == COLUMN_PID) { l1 = Param1->ProcessId; l2 = Param2->ProcessId; ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_USERNAME) { PerfDataGetUserName(IndexParam1, text1, sizeof (text1) / sizeof (*text1)); PerfDataGetUserName(IndexParam2, text2, sizeof (text2) / sizeof (*text2)); ret = _wcsicmp(text1, text2); } else if (TaskManagerSettings.SortColumn == COLUMN_SESSIONID) { l1 = PerfDataGetSessionId(IndexParam1); l2 = PerfDataGetSessionId(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_CPUUSAGE) { l1 = PerfDataGetCPUUsage(IndexParam1); l2 = PerfDataGetCPUUsage(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_CPUTIME) { time1 = PerfDataGetCPUTime(IndexParam1); time2 = PerfDataGetCPUTime(IndexParam2); ret = largeintcmp(time1, time2); } else if (TaskManagerSettings.SortColumn == COLUMN_MEMORYUSAGE) { l1 = PerfDataGetWorkingSetSizeBytes(IndexParam1); l2 = PerfDataGetWorkingSetSizeBytes(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_PEAKMEMORYUSAGE) { l1 = PerfDataGetPeakWorkingSetSizeBytes(IndexParam1); l2 = PerfDataGetPeakWorkingSetSizeBytes(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_MEMORYUSAGEDELTA) { l1 = PerfDataGetWorkingSetSizeDelta(IndexParam1); l2 = PerfDataGetWorkingSetSizeDelta(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_PAGEFAULTS) { l1 = PerfDataGetPageFaultCount(IndexParam1); l2 = PerfDataGetPageFaultCount(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_PAGEFAULTSDELTA) { l1 = PerfDataGetPageFaultCountDelta(IndexParam1); l2 = PerfDataGetPageFaultCountDelta(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_VIRTUALMEMORYSIZE) { l1 = PerfDataGetVirtualMemorySizeBytes(IndexParam1); l2 = PerfDataGetVirtualMemorySizeBytes(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_PAGEDPOOL) { l1 = PerfDataGetPagedPoolUsagePages(IndexParam1); l2 = PerfDataGetPagedPoolUsagePages(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_NONPAGEDPOOL) { l1 = PerfDataGetNonPagedPoolUsagePages(IndexParam1); l2 = PerfDataGetNonPagedPoolUsagePages(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_BASEPRIORITY) { l1 = PerfDataGetBasePriority(IndexParam1); l2 = PerfDataGetBasePriority(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_HANDLECOUNT) { l1 = PerfDataGetHandleCount(IndexParam1); l2 = PerfDataGetHandleCount(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_THREADCOUNT) { l1 = PerfDataGetThreadCount(IndexParam1); l2 = PerfDataGetThreadCount(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_USEROBJECTS) { l1 = PerfDataGetUSERObjectCount(IndexParam1); l2 = PerfDataGetUSERObjectCount(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_GDIOBJECTS) { l1 = PerfDataGetGDIObjectCount(IndexParam1); l2 = PerfDataGetGDIObjectCount(IndexParam2); ret = CMP(l1, l2); } else if (TaskManagerSettings.SortColumn == COLUMN_IOREADS) { PerfDataGetIOCounters(IndexParam1, &iocounters1); PerfDataGetIOCounters(IndexParam2, &iocounters2); ull1 = iocounters1.ReadOperationCount; ull2 = iocounters2.ReadOperationCount; ret = CMP(ull1, ull2); } else if (TaskManagerSettings.SortColumn == COLUMN_IOWRITES) { PerfDataGetIOCounters(IndexParam1, &iocounters1); PerfDataGetIOCounters(IndexParam2, &iocounters2); ull1 = iocounters1.WriteOperationCount; ull2 = iocounters2.WriteOperationCount; ret = CMP(ull1, ull2); } else if (TaskManagerSettings.SortColumn == COLUMN_IOOTHER) { PerfDataGetIOCounters(IndexParam1, &iocounters1); PerfDataGetIOCounters(IndexParam2, &iocounters2); ull1 = iocounters1.OtherOperationCount; ull2 = iocounters2.OtherOperationCount; ret = CMP(ull1, ull2); } else if (TaskManagerSettings.SortColumn == COLUMN_IOREADBYTES) { PerfDataGetIOCounters(IndexParam1, &iocounters1); PerfDataGetIOCounters(IndexParam2, &iocounters2); ull1 = iocounters1.ReadTransferCount; ull2 = iocounters2.ReadTransferCount; ret = CMP(ull1, ull2); } else if (TaskManagerSettings.SortColumn == COLUMN_IOWRITEBYTES) { PerfDataGetIOCounters(IndexParam1, &iocounters1); PerfDataGetIOCounters(IndexParam2, &iocounters2); ull1 = iocounters1.WriteTransferCount; ull2 = iocounters2.WriteTransferCount; ret = CMP(ull1, ull2); } else if (TaskManagerSettings.SortColumn == COLUMN_IOOTHERBYTES) { PerfDataGetIOCounters(IndexParam1, &iocounters1); PerfDataGetIOCounters(IndexParam2, &iocounters2); ull1 = iocounters1.OtherTransferCount; ull2 = iocounters2.OtherTransferCount; ret = CMP(ull1, ull2); } return ret; }
static void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam) { int idctrl; LPNMHDR pnmh; LPNMLISTVIEW pnmv; NMLVDISPINFO* pnmdi; LPNMHEADER pnmhdr; LVITEM lvitem; ULONG Index; ULONG ColumnIndex; IO_COUNTERS iocounters; TIME time; idctrl = (int) wParam; pnmh = (LPNMHDR) lParam; pnmv = (LPNMLISTVIEW) lParam; pnmdi = (NMLVDISPINFO*) lParam; pnmhdr = (LPNMHEADER) lParam; if (pnmh->hwndFrom == hProcessPageListCtrl) { switch (pnmh->code) { #if 0 case LVN_ITEMCHANGED: ProcessPageUpdate(); break; #endif case LVN_GETDISPINFO: if (!(pnmdi->item.mask & LVIF_TEXT)) break; ColumnIndex = pnmdi->item.iSubItem; Index = pnmdi->item.iItem; if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME) PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); if (ColumnDataHints[ColumnIndex] == COLUMN_PID) wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetProcessId(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME) PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID) wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetSessionId(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE) wsprintf(pnmdi->item.pszText, _T("%02d"), PerfDataGetCPUUsage(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME) { DWORD dwHours; DWORD dwMinutes; DWORD dwSeconds; ULONGLONG secs; time = PerfDataGetCPUTime(Index); secs = time.QuadPart / 10000000; dwHours = secs / 3600; dwMinutes = (secs % 3600) / 60; dwSeconds = (secs % 3600) % 60; wsprintf(pnmdi->item.pszText, _T("%d:%02d:%02d"), dwHours, dwMinutes, dwSeconds); } if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); _tcscat(pnmdi->item.pszText, _T(" K")); } if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); _tcscat(pnmdi->item.pszText, _T(" K")); } if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeDelta(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); _tcscat(pnmdi->item.pszText, _T(" K")); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCountDelta(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetVirtualMemorySizeBytes(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); _tcscat(pnmdi->item.pszText, _T(" K")); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); _tcscat(pnmdi->item.pszText, _T(" K")); } if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetNonPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); _tcscat(pnmdi->item.pszText, _T(" K")); } if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY) wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetBasePriority(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetHandleCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetThreadCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetUSERObjectCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS) { wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetGDIObjectCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadOperationCount); */ #ifdef UNICODE #define _ui64toa _ui64tow #else #endif _ui64toa(iocounters.ReadOperationCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteOperationCount); */ _ui64toa(iocounters.WriteOperationCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherOperationCount); */ _ui64toa(iocounters.OtherOperationCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadTransferCount); */ _ui64toa(iocounters.ReadTransferCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteTransferCount); */ _ui64toa(iocounters.WriteTransferCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherTransferCount); */ _ui64toa(iocounters.OtherTransferCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } break; case NM_RCLICK: for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) { memset(&lvitem, 0, sizeof(LVITEM)); lvitem.mask = LVIF_STATE; lvitem.stateMask = LVIS_SELECTED; lvitem.iItem = Index; SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem); if (lvitem.state & LVIS_SELECTED) break; } if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) && (PerfDataGetProcessId(Index) != 0)) { ProcessPageShowContextMenu(PerfDataGetProcessId(Index)); } break; } } else if (pnmh->hwndFrom == hProcessPageHeaderCtrl) { switch (pnmh->code) { case HDN_ITEMCLICK: /* * FIXME: Fix the column sorting * *ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL); *bSortAscending = !bSortAscending; */ break; case HDN_ITEMCHANGED: UpdateColumnDataHints(); break; case HDN_ENDDRAG: UpdateColumnDataHints(); break; } } }
BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCount) { IO_COUNTERS iocounters; LARGE_INTEGER time; if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME) PerfDataGetImageName(Index, lpText, nMaxCount); if (ColumnDataHints[ColumnIndex] == COLUMN_PID) wsprintfW(lpText, L"%lu", PerfDataGetProcessId(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME) PerfDataGetUserName(Index, lpText, nMaxCount); if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID) wsprintfW(lpText, L"%lu", PerfDataGetSessionId(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE) wsprintfW(lpText, L"%02lu", PerfDataGetCPUUsage(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME) { DWORD dwHours; DWORD dwMinutes; DWORD dwSeconds; time = PerfDataGetCPUTime(Index); gethmsfromlargeint(time, &dwHours, &dwMinutes, &dwSeconds); wsprintfW(lpText, L"%lu:%02lu:%02lu", dwHours, dwMinutes, dwSeconds); } if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE) { wsprintfW(lpText, L"%lu", PerfDataGetWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE) { wsprintfW(lpText, L"%lu", PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA) { wsprintfW(lpText, L"%lu", PerfDataGetWorkingSetSizeDelta(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS) { wsprintfW(lpText, L"%lu", PerfDataGetPageFaultCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA) { wsprintfW(lpText, L"%lu", PerfDataGetPageFaultCountDelta(Index)); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE) { wsprintfW(lpText, L"%lu", PerfDataGetVirtualMemorySizeBytes(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL) { wsprintfW(lpText, L"%lu", PerfDataGetPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL) { wsprintfW(lpText, L"%lu", PerfDataGetNonPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY) wsprintfW(lpText, L"%lu", PerfDataGetBasePriority(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT) { wsprintfW(lpText, L"%lu", PerfDataGetHandleCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT) { wsprintfW(lpText, L"%lu", PerfDataGetThreadCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS) { wsprintfW(lpText, L"%lu", PerfDataGetUSERObjectCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS) { wsprintfW(lpText, L"%lu", PerfDataGetGDIObjectCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.ReadOperationCount); */ _ui64tow(iocounters.ReadOperationCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.WriteOperationCount); */ _ui64tow(iocounters.WriteOperationCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.OtherOperationCount); */ _ui64tow(iocounters.OtherOperationCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.ReadTransferCount); */ _ui64tow(iocounters.ReadTransferCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.WriteTransferCount); */ _ui64tow(iocounters.WriteTransferCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.OtherTransferCount); */ _ui64tow(iocounters.OtherTransferCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } return FALSE; }
static void ProcessPageOnNotify(LPARAM lParam) { LPNMHDR pnmh; NMLVDISPINFOW* pnmdi; LVITEMW lvitem; ULONG Index, Count; ULONG ColumnIndex; IO_COUNTERS iocounters; TIME time; static const WCHAR wszFmtD[] = {'%','d',0}; static const WCHAR wszFmt02D[] = {'%','0','2','d',0}; static const WCHAR wszUnitK[] = {' ','K',0}; pnmh = (LPNMHDR) lParam; pnmdi = (NMLVDISPINFOW*) lParam; if (pnmh->hwndFrom == hProcessPageListCtrl) { switch (pnmh->code) { #if 0 case LVN_ITEMCHANGED: ProcessPageUpdate(); break; #endif case LVN_GETDISPINFOW: if (!(pnmdi->item.mask & LVIF_TEXT)) break; ColumnIndex = pnmdi->item.iSubItem; Index = pnmdi->item.iItem; if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME) PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); if (ColumnDataHints[ColumnIndex] == COLUMN_PID) wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetProcessId(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME) PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID) wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetSessionId(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE) wsprintfW(pnmdi->item.pszText, wszFmt02D, PerfDataGetCPUUsage(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME) { DWORD dwHours; DWORD dwMinutes; DWORD dwSeconds; ULONGLONG secs; static const WCHAR timefmt[] = {'%','d',':','%','0','2','d',':','%','0','2','d',0}; time = PerfDataGetCPUTime(Index); secs = time.QuadPart / 10000000; dwHours = secs / 3600; dwMinutes = (secs % 3600) / 60; dwSeconds = (secs % 3600) % 60; wsprintfW(pnmdi->item.pszText, timefmt, dwHours, dwMinutes, dwSeconds); } if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); wcscat(pnmdi->item.pszText, wszUnitK); } if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); wcscat(pnmdi->item.pszText, wszUnitK); } if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetWorkingSetSizeDelta(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); wcscat(pnmdi->item.pszText, wszUnitK); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPageFaultCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPageFaultCountDelta(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetVirtualMemorySizeBytes(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); wcscat(pnmdi->item.pszText, wszUnitK); } if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); wcscat(pnmdi->item.pszText, wszUnitK); } if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetNonPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); wcscat(pnmdi->item.pszText, wszUnitK); } if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY) wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetBasePriority(Index)); if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetHandleCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetThreadCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetUSERObjectCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS) { wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetGDIObjectCount(Index)); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.ReadOperationCount); */ _ui64tow(iocounters.ReadOperationCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.WriteOperationCount); */ _ui64tow(iocounters.WriteOperationCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.OtherOperationCount); */ _ui64tow(iocounters.OtherOperationCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.ReadTransferCount); */ _ui64tow(iocounters.ReadTransferCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.WriteTransferCount); */ _ui64tow(iocounters.WriteTransferCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES) { PerfDataGetIOCounters(Index, &iocounters); /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.OtherTransferCount); */ _ui64tow(iocounters.OtherTransferCount, pnmdi->item.pszText, 10); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); } break; case NM_RCLICK: Count = SendMessageW(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0); for (Index=0; Index<Count; Index++) { lvitem.mask = LVIF_STATE; lvitem.stateMask = LVIS_SELECTED; lvitem.iItem = Index; lvitem.iSubItem = 0; SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem); if (lvitem.state & LVIS_SELECTED) break; } if ((SendMessageW(hProcessPageListCtrl, LVM_GETSELECTEDCOUNT, 0, 0) == 1) && (PerfDataGetProcessId(Index) != 0)) { ProcessPageShowContextMenu(PerfDataGetProcessId(Index)); } break; } } else if (pnmh->hwndFrom == hProcessPageHeaderCtrl) { switch (pnmh->code) { case HDN_ITEMCLICKW: /* * FIXME: Fix the column sorting * *ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL); *bSortAscending = !bSortAscending; */ break; case HDN_ITEMCHANGEDW: UpdateColumnDataHints(); break; case HDN_ENDDRAG: UpdateColumnDataHints(); break; } } }