modified base/applications/taskmgr/affinity.c
authorKJK::Hyperion <hackbunny@reactos.org>
Sun, 28 Jun 2009 14:22:09 +0000 (14:22 +0000)
committerKJK::Hyperion <hackbunny@reactos.org>
Sun, 28 Jun 2009 14:22:09 +0000 (14:22 +0000)
modified   base/applications/taskmgr/debug.c
modified   base/applications/taskmgr/endproc.c
modified   base/applications/taskmgr/priority.c
   Arch Blackmann has never heard of exotic features of the C language such as "subroutines"

modified   base/applications/taskmgr/dbgchnl.c
modified   base/applications/taskmgr/procpage.c
modified   base/applications/taskmgr/procpage.h
   Did you know that Task Manager killed the wrong process when using the context menu? Fixed by using a sophisticated "subroutine" that reads the process entry index from the currently selected list item's client data, replacing the copy-pasted code that used the index of the list entry as the process entry index (which only worked before due to no sorting)
   Save the sort column and order

modified   base/applications/taskmgr/taskmgr.c
   Sort by image name by default

svn path=/trunk/; revision=41664

reactos/base/applications/taskmgr/affinity.c
reactos/base/applications/taskmgr/dbgchnl.c
reactos/base/applications/taskmgr/debug.c
reactos/base/applications/taskmgr/endproc.c
reactos/base/applications/taskmgr/priority.c
reactos/base/applications/taskmgr/procpage.c
reactos/base/applications/taskmgr/procpage.h
reactos/base/applications/taskmgr/taskmgr.c

index 0b96bef..58a2250 100644 (file)
@@ -40,24 +40,15 @@ static INT_PTR CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wP
 
 void ProcessPage_OnSetAffinity(void)
 {
-    LV_ITEM  lvitem;
-    ULONG    Index;
     DWORD    dwProcessId;
     WCHAR    strErrorText[260];
     WCHAR    szTitle[256];
 
-    for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) {
-        memset(&lvitem, 0, sizeof(LV_ITEM));
-        lvitem.mask = LVIF_STATE;
-        lvitem.stateMask = LVIS_SELECTED;
-        lvitem.iItem = Index;
-        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-        if (lvitem.state & LVIS_SELECTED)
-            break;
-    }
-    dwProcessId = PerfDataGetProcessId(Index);
-    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
+    dwProcessId = GetSelectedProcessId();
+
+    if (dwProcessId == 0)
         return;
+
     hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
     if (!hProcessAffinityHandle) {
         GetLastErrorText(strErrorText, sizeof(strErrorText) / sizeof(WCHAR));
index b1f34d3..b39774c 100644 (file)
@@ -42,33 +42,6 @@ BOOL DebugChannelsAreSupported(void)
     return FALSE;
 }
 
-static DWORD    get_selected_pid(void)
-{
-    LVITEM  lvitem;
-    ULONG   Index;
-    DWORD   dwProcessId;
-
-    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;
-
-        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-
-        if (lvitem.state & LVIS_SELECTED)
-            break;
-    }
-
-    dwProcessId = PerfDataGetProcessId(Index);
-
-    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
-        return 0;
-    return dwProcessId;
-}
-
 static int     list_channel_CB(HANDLE hProcess, void* addr, WCHAR* buffer, void* user)
 {
     int     j;
@@ -290,7 +263,7 @@ static void DebugChannels_FillList(HWND hChannelLV)
 
     (void)ListView_DeleteAllItems(hChannelLV);
 
-    hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ, FALSE, get_selected_pid());
+    hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ, FALSE, GetSelectedProcessId());
     if (!hProcess) return; /* FIXME messagebox */
     SendMessageW(hChannelLV, WM_SETREDRAW, FALSE, 0);
     enum_channel(hProcess, list_channel_CB, (void*)hChannelLV, TRUE);
@@ -350,7 +323,7 @@ static void DebugChannels_OnNotify(HWND hDlg, LPARAM lParam)
             HANDLE           hProcess;
             NMITEMACTIVATE*  nmia = (NMITEMACTIVATE*)lParam;
 
-            hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, get_selected_pid());
+            hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, GetSelectedProcessId());
             if (!hProcess) return; /* FIXME message box */
             lhti.pt = nmia->ptAction;
             hChannelLV = GetDlgItem(hDlg, IDC_DEBUG_CHANNELS_LIST);
index 9c1f870..20d588e 100644 (file)
@@ -25,8 +25,6 @@
 
 void ProcessPage_OnDebug(void)
 {
-    LVITEM               lvitem;
-    ULONG                Index;
     DWORD                dwProcessId;
     WCHAR                strErrorText[260];
     HKEY                 hKey;
@@ -39,24 +37,9 @@ void ProcessPage_OnDebug(void)
     WCHAR                szTemp[256];
     WCHAR                szTempA[256];
 
+    dwProcessId = GetSelectedProcessId();
 
-    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;
-
-        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-
-        if (lvitem.state & LVIS_SELECTED)
-            break;
-    }
-
-    dwProcessId = PerfDataGetProcessId(Index);
-
-    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
+    if (dwProcessId == 0)
         return;
 
     LoadStringW(hInst, IDS_MSG_WARNINGDEBUG, szTemp, 256);
index 33f297c..ef61796 100644 (file)
 
 void ProcessPage_OnEndProcess(void)
 {
-    LVITEM  lvitem;
-    ULONG   Index;
     DWORD   dwProcessId;
     HANDLE  hProcess;
     WCHAR   szTitle[256];
     WCHAR   strErrorText[260];
 
-    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;
-
-        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-
-        if (lvitem.state & LVIS_SELECTED)
-            break;
-    }
-
-    dwProcessId = PerfDataGetProcessId(Index);
+    dwProcessId = GetSelectedProcessId();
 
-    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
+    if (dwProcessId == 0)
         return;
 
     LoadStringW(hInst, IDS_MSG_WARNINGTERMINATING, strErrorText, 256);
@@ -78,30 +62,14 @@ void ProcessPage_OnEndProcess(void)
 
 void ProcessPage_OnEndProcessTree(void)
 {
-    LVITEM  lvitem;
-    ULONG   Index;
     DWORD   dwProcessId;
     HANDLE  hProcess;
     WCHAR   szTitle[256];
     WCHAR   strErrorText[260];
 
-    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;
-
-        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-
-        if (lvitem.state & LVIS_SELECTED)
-            break;
-    }
-
-    dwProcessId = PerfDataGetProcessId(Index);
+    dwProcessId = GetSelectedProcessId();
 
-    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
+    if (dwProcessId == 0)
         return;
 
     LoadStringW(hInst, IDS_MSG_WARNINGTERMINATING, strErrorText, 256);
index 243dd51..cd18600 100644 (file)
 
 void DoSetPriority(DWORD priority)
 {
-    LVITEM  lvitem;
-    ULONG   Index;
     DWORD   dwProcessId;
     HANDLE  hProcess;
     WCHAR   szText[260];
     WCHAR   szTitle[256];
 
-    for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
-    {
-        ZeroMemory(&lvitem, sizeof(LVITEM));
-
-        lvitem.mask = LVIF_STATE;
-        lvitem.stateMask = LVIS_SELECTED;
-        lvitem.iItem = Index;
-
-        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-
-        if (lvitem.state & LVIS_SELECTED)
-            break;
-    }
-
-    dwProcessId = PerfDataGetProcessId(Index);
+    dwProcessId = GetSelectedProcessId();
 
-    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
+    if (dwProcessId == 0)
         return;
 
     LoadStringW(hInst, IDS_MSG_TASKMGRWARNING, szTitle, 256);
index 8400862..d2f59fe 100644 (file)
@@ -40,10 +40,7 @@ HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox *
 
 static int  nProcessPageWidth;
 static int  nProcessPageHeight;
-static BOOL    bProcessSort = FALSE;
-static BOOL    bProcessSortAscending = FALSE;
 static HANDLE  hProcessPageEvent = NULL;    /* When this event becomes signaled then we refresh the process list */
-static ULONG   ProcessSortColumnIndex = 0;
 
 int CALLBACK    ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
 void AddProcess(ULONG Index);
@@ -55,6 +52,29 @@ void ProcessPageShowContextMenu(DWORD dwProcessId);
 BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCount);
 DWORD WINAPI ProcessPageRefreshThread(void *lpParameter);
 
+DWORD GetSelectedProcessId(void)
+{
+    int     Index;
+    LVITEM  lvitem;
+
+    if(ListView_GetSelectedCount(hProcessPageListCtrl) == 1)
+    {
+        Index = ListView_GetSelectionMark(hProcessPageListCtrl);
+
+        memset(&lvitem, 0, sizeof(LVITEM));
+
+        lvitem.mask = LVIF_PARAM;
+        lvitem.iItem = Index;
+
+        (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
+
+        if (lvitem.lParam)
+            return PerfDataGetProcessId(((LPPROCESS_PAGE_LIST_ITEM)lvitem.lParam)->Index);
+    }
+
+    return 0;
+}
+
 INT_PTR CALLBACK
 ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 {
@@ -171,7 +191,6 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
     LPNMLISTVIEW   pnmv;
     NMLVDISPINFO*  pnmdi;
     LPNMHEADER     pnmhdr;
-    LVITEM         lvitem;
     ULONG          Index;
     ULONG          ColumnIndex;
     LPPROCESS_PAGE_LIST_ITEM  pData;
@@ -207,26 +226,7 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
 
         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;
-
-                (void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
-
-                if (lvitem.state & LVIS_SELECTED)
-                    break;
-            }
-
-            if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) &&
-                (PerfDataGetProcessId(Index) != 0))
-            {
-                ProcessPageShowContextMenu(PerfDataGetProcessId(Index));
-            }
-
+            ProcessPageShowContextMenu(GetSelectedProcessId());
             break;
 
         }
@@ -237,10 +237,9 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
         {
         case HDN_ITEMCLICK:
 
-            ProcessSortColumnIndex = pnmhdr->iItem;
-            bProcessSortAscending = !bProcessSortAscending;
+            TaskManagerSettings.SortColumn = ColumnDataHints[pnmhdr->iItem];
+            TaskManagerSettings.SortAscending = !TaskManagerSettings.SortAscending;
             (void)ListView_SortItems(hProcessPageListCtrl, ProcessPageCompareFunc, NULL);
-            bProcessSort = TRUE;
 
             break;
 
@@ -447,7 +446,7 @@ void UpdateProcesses()
     {
         AddProcess(l);
     }
-    if (bProcessSort)
+    if (TaskManagerSettings.SortColumn != -1)
     {
         (void)ListView_SortItems(hProcessPageListCtrl, ProcessPageCompareFunc, NULL);
     }
@@ -674,7 +673,6 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
     int ret = 0;
     LPPROCESS_PAGE_LIST_ITEM Param1;
     LPPROCESS_PAGE_LIST_ITEM Param2;
-    ULONG ColumnIndex;
     WCHAR text1[260];
     WCHAR text2[260];
     ULONG l1;
@@ -686,130 +684,129 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
     ULONGLONG      ull1;
     ULONGLONG      ull2;
 
-    if (bProcessSortAscending) {
+    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;
     }
-    ColumnIndex = ProcessSortColumnIndex;
 
-    if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME)
+    if (TaskManagerSettings.SortColumn == COLUMN_IMAGENAME)
     {
         PerfDataGetImageName(Param1->Index, text1, sizeof (text1) / sizeof (*text1));
         PerfDataGetImageName(Param2->Index, text2, sizeof (text2) / sizeof (*text2));
         ret = _wcsicmp(text1, text2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_PID)
+    else if (TaskManagerSettings.SortColumn == COLUMN_PID)
     {
         l1 = PerfDataGetProcessId(Param1->Index);
         l2 = PerfDataGetProcessId(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME)
+    else if (TaskManagerSettings.SortColumn == COLUMN_USERNAME)
     {
         PerfDataGetUserName(Param1->Index, text1, sizeof (text1) / sizeof (*text1));
         PerfDataGetUserName(Param2->Index, text2, sizeof (text2) / sizeof (*text2));
         ret = _wcsicmp(text1, text2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID)
+    else if (TaskManagerSettings.SortColumn == COLUMN_SESSIONID)
     {
         l1 = PerfDataGetSessionId(Param1->Index);
         l2 = PerfDataGetSessionId(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE)
+    else if (TaskManagerSettings.SortColumn == COLUMN_CPUUSAGE)
     {
         l1 = PerfDataGetCPUUsage(Param1->Index);
         l2 = PerfDataGetCPUUsage(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME)
+    else if (TaskManagerSettings.SortColumn == COLUMN_CPUTIME)
     {
         time1 = PerfDataGetCPUTime(Param1->Index);
         time2 = PerfDataGetCPUTime(Param2->Index);
         ret = largeintcmp(time1, time2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE)
+    else if (TaskManagerSettings.SortColumn == COLUMN_MEMORYUSAGE)
     {
         l1 = PerfDataGetWorkingSetSizeBytes(Param1->Index);
         l2 = PerfDataGetWorkingSetSizeBytes(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE)
+    else if (TaskManagerSettings.SortColumn == COLUMN_PEAKMEMORYUSAGE)
     {
         l1 = PerfDataGetPeakWorkingSetSizeBytes(Param1->Index);
         l2 = PerfDataGetPeakWorkingSetSizeBytes(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA)
+    else if (TaskManagerSettings.SortColumn == COLUMN_MEMORYUSAGEDELTA)
     {
         l1 = PerfDataGetWorkingSetSizeDelta(Param1->Index);
         l2 = PerfDataGetWorkingSetSizeDelta(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS)
+    else if (TaskManagerSettings.SortColumn == COLUMN_PAGEFAULTS)
     {
         l1 = PerfDataGetPageFaultCount(Param1->Index);
         l2 = PerfDataGetPageFaultCount(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA)
+    else if (TaskManagerSettings.SortColumn == COLUMN_PAGEFAULTSDELTA)
     {
         l1 = PerfDataGetPageFaultCountDelta(Param1->Index);
         l2 = PerfDataGetPageFaultCountDelta(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE)
+    else if (TaskManagerSettings.SortColumn == COLUMN_VIRTUALMEMORYSIZE)
     {
         l1 = PerfDataGetVirtualMemorySizeBytes(Param1->Index);
         l2 = PerfDataGetVirtualMemorySizeBytes(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL)
+    else if (TaskManagerSettings.SortColumn == COLUMN_PAGEDPOOL)
     {
         l1 = PerfDataGetPagedPoolUsagePages(Param1->Index);
         l2 = PerfDataGetPagedPoolUsagePages(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL)
+    else if (TaskManagerSettings.SortColumn == COLUMN_NONPAGEDPOOL)
     {
         l1 = PerfDataGetNonPagedPoolUsagePages(Param1->Index);
         l2 = PerfDataGetNonPagedPoolUsagePages(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY)
+    else if (TaskManagerSettings.SortColumn == COLUMN_BASEPRIORITY)
     {
         l1 = PerfDataGetBasePriority(Param1->Index);
         l2 = PerfDataGetBasePriority(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT)
+    else if (TaskManagerSettings.SortColumn == COLUMN_HANDLECOUNT)
     {
         l1 = PerfDataGetHandleCount(Param1->Index);
         l2 = PerfDataGetHandleCount(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT)
+    else if (TaskManagerSettings.SortColumn == COLUMN_THREADCOUNT)
     {
         l1 = PerfDataGetThreadCount(Param1->Index);
         l2 = PerfDataGetThreadCount(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS)
+    else if (TaskManagerSettings.SortColumn == COLUMN_USEROBJECTS)
     {
         l1 = PerfDataGetUSERObjectCount(Param1->Index);
         l2 = PerfDataGetUSERObjectCount(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS)
+    else if (TaskManagerSettings.SortColumn == COLUMN_GDIOBJECTS)
     {
         l1 = PerfDataGetGDIObjectCount(Param1->Index);
         l2 = PerfDataGetGDIObjectCount(Param2->Index);
         ret = CMP(l1, l2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS)
+    else if (TaskManagerSettings.SortColumn == COLUMN_IOREADS)
     {
         PerfDataGetIOCounters(Param1->Index, &iocounters1);
         PerfDataGetIOCounters(Param2->Index, &iocounters2);
@@ -817,7 +814,7 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
         ull2 = iocounters2.ReadOperationCount;
         ret = CMP(ull1, ull2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES)
+    else if (TaskManagerSettings.SortColumn == COLUMN_IOWRITES)
     {
         PerfDataGetIOCounters(Param1->Index, &iocounters1);
         PerfDataGetIOCounters(Param2->Index, &iocounters2);
@@ -825,7 +822,7 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
         ull2 = iocounters2.WriteOperationCount;
         ret = CMP(ull1, ull2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER)
+    else if (TaskManagerSettings.SortColumn == COLUMN_IOOTHER)
     {
         PerfDataGetIOCounters(Param1->Index, &iocounters1);
         PerfDataGetIOCounters(Param2->Index, &iocounters2);
@@ -833,7 +830,7 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
         ull2 = iocounters2.OtherOperationCount;
         ret = CMP(ull1, ull2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES)
+    else if (TaskManagerSettings.SortColumn == COLUMN_IOREADBYTES)
     {
         PerfDataGetIOCounters(Param1->Index, &iocounters1);
         PerfDataGetIOCounters(Param2->Index, &iocounters2);
@@ -841,7 +838,7 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
         ull2 = iocounters2.ReadTransferCount;
         ret = CMP(ull1, ull2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES)
+    else if (TaskManagerSettings.SortColumn == COLUMN_IOWRITEBYTES)
     {
         PerfDataGetIOCounters(Param1->Index, &iocounters1);
         PerfDataGetIOCounters(Param2->Index, &iocounters2);
@@ -849,7 +846,7 @@ int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPara
         ull2 = iocounters2.WriteTransferCount;
         ret = CMP(ull1, ull2);
     }
-    else if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES)
+    else if (TaskManagerSettings.SortColumn == COLUMN_IOOTHERBYTES)
     {
         PerfDataGetIOCounters(Param1->Index, &iocounters1);
         PerfDataGetIOCounters(Param2->Index, &iocounters2);
index 439e2a9..8cfb7eb 100644 (file)
@@ -31,5 +31,6 @@ extern        HWND            hProcessPageShowAllProcessesButton;     /* Process Show All Processes c
 
 INT_PTR CALLBACK       ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
 void                           RefreshProcessPage(void);
+DWORD               GetSelectedProcessId(void);
 
 #endif /* __PROCESSPAGE_H */
index c12aea5..7ce4668 100644 (file)
@@ -706,7 +706,7 @@ void LoadSettings(void)
         TaskManagerSettings.ColumnSizeArray[i] = ColumnPresets[i].size;
     }
 
-    TaskManagerSettings.SortColumn = 1;
+    TaskManagerSettings.SortColumn = COLUMN_IMAGENAME;
     TaskManagerSettings.SortAscending = TRUE;
 
     /* Performance page settings */