From b4cd6622eb6ec4a10184e19e883bbd3fbcccc4e2 Mon Sep 17 00:00:00 2001 From: Wen Jia Liu Date: Wed, 7 Jul 2010 09:48:56 +0000 Subject: [PATCH] * process tree column settings are now saved * added I/O Total and Description columns --- ProcessHacker/ProcessHacker.rc | 2 +- ProcessHacker/include/phapp.h | 56 ++++++- ProcessHacker/include/settings.h | 2 + ProcessHacker/mainwnd.c | 9 +- ProcessHacker/proctree.c | 58 +++++++- ProcessHacker/settings.c | 3 + ProcessHacker/support.c | 24 +++ phlib/include/treelist.h | 17 ++- phlib/treelist.c | 243 ++++++++++++++++++++++++++++--- 9 files changed, 377 insertions(+), 37 deletions(-) diff --git a/ProcessHacker/ProcessHacker.rc b/ProcessHacker/ProcessHacker.rc index 69fcd0525..4af855917 100644 --- a/ProcessHacker/ProcessHacker.rc +++ b/ProcessHacker/ProcessHacker.rc @@ -1052,7 +1052,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,134,186,50,14 PUSHBUTTON "Cancel",IDCANCEL,188,186,50,14 LTEXT "Select the columns that will appear in the list.",IDC_MESSAGE,7,7,231,18 - LISTBOX IDC_LIST2,7,31,175,150,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_LIST,7,31,175,150,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Move Up",IDC_MOVEUP,188,30,50,14 PUSHBUTTON "Move Down",IDC_MOVEDOWN,188,48,50,14 END diff --git a/ProcessHacker/include/phapp.h b/ProcessHacker/include/phapp.h index 90f7517a3..bf4b6625d 100644 --- a/ProcessHacker/include/phapp.h +++ b/ProcessHacker/include/phapp.h @@ -99,9 +99,45 @@ ATOM PhRegisterWindowClass(); #define PHTLC_NAME 0 #define PHTLC_PID 1 #define PHTLC_CPU 2 -#define PHTLC_PVTMEMORY 3 -#define PHTLC_USERNAME 4 -#define PHTLC_MAXIMUM 5 +#define PHTLC_IOTOTAL 3 +#define PHTLC_PVTMEMORY 4 +#define PHTLC_USERNAME 5 +#define PHTLC_DESCRIPTION 6 + +#define PHTLC_COMPANYNAME 7 +#define PHTLC_FILENAME 8 +#define PHTLC_COMMANDLINE 9 + +#define PHTLC_PEAKPVTMEMORY 10 +#define PHTLC_WORKINGSET 11 +#define PHTLC_PEAKWORKINGSET 12 +#define PHTLC_PRIVATEWS 13 +#define PHTLC_SHAREDWS 14 +#define PHTLC_SHAREABLEWS 15 +#define PHTLC_VIRTUALSIZE 16 +#define PHTLC_PEAKVIRTUALSIZE 17 +#define PHTLC_PAGEFAULTS 18 +#define PHTLC_SESSIONID 19 +#define PHTLC_PRIORITYCLASS 20 +#define PHTLC_BASEPRIORITY 21 + +#define PHTLC_THREADS 22 +#define PHTLC_HANDLES 23 +#define PHTLC_GDIHANDLES 24 +#define PHTLC_USERHANDLES 25 +#define PHTLC_IORO 26 +#define PHTLC_IOW 27 +#define PHTLC_INTEGRITY 28 +#define PHTLC_IOPRIORITY 29 +#define PHTLC_PAGEPRIORITY 30 +#define PHTLC_STARTTIME 31 +#define PHTLC_TOTALCPUTIME 32 +#define PHTLC_KERNELCPUTIME 33 +#define PHTLC_USERCPUTIME 34 +#define PHTLC_VERIFICATIONSTATUS 35 +#define PHTLC_VERIFIEDSIGNER 36 + +#define PHTLC_MAXIMUM 37 typedef struct _PH_PROCESS_NODE { @@ -119,8 +155,10 @@ typedef struct _PH_PROCESS_NODE PH_STRINGREF TextCache[PHTLC_MAXIMUM]; - PPH_STRING PrivateMemoryText; PPH_STRING TooltipText; + + PPH_STRING IoTotalText; + PPH_STRING PrivateMemoryText; } PH_PROCESS_NODE, *PPH_PROCESS_NODE; VOID PhProcessTreeListInitialization(); @@ -249,6 +287,16 @@ VOID PhSaveListViewColumnsToSetting( __in HWND ListViewHandle ); +VOID PhLoadTreeListColumnsFromSetting( + __in PWSTR Name, + __in HWND TreeListHandle + ); + +VOID PhSaveTreeListColumnsToSetting( + __in PWSTR Name, + __in HWND TreeListHandle + ); + #define PH_LOAD_SHARED_IMAGE(Name, Type) LoadImage(PhInstanceHandle, (Name), (Type), 0, 0, LR_SHARED) FORCEINLINE PVOID PhpGenericPropertyPageHeader( diff --git a/ProcessHacker/include/settings.h b/ProcessHacker/include/settings.h index c45551fe9..6b2ab8753 100644 --- a/ProcessHacker/include/settings.h +++ b/ProcessHacker/include/settings.h @@ -73,6 +73,8 @@ NTSTATUS PhSaveSettings( #define EXT extern #endif +EXT ULONG PhCsUpdateInterval; + EXT ULONG PhCsColorNew; EXT ULONG PhCsColorRemoved; EXT ULONG PhCsUseColorOwnProcesses; diff --git a/ProcessHacker/mainwnd.c b/ProcessHacker/mainwnd.c index 6ab0d646e..4b5a0693b 100644 --- a/ProcessHacker/mainwnd.c +++ b/ProcessHacker/mainwnd.c @@ -341,6 +341,11 @@ BOOLEAN PhMainWndInitialization( { ULONG interval = PhGetIntegerSetting(L"UpdateInterval"); + if (interval == 0) + { + PH_SET_INTEGER_CACHED_SETTING(UpdateInterval, 1000); + } + PhInitializeProviderThread(&PhPrimaryProviderThread, interval); PhInitializeProviderThread(&PhSecondaryProviderThread, interval); } @@ -721,7 +726,7 @@ LRESULT CALLBACK PhMainWndProc( break; } - PhSetIntegerSetting(L"UpdateInterval", interval); + PH_SET_INTEGER_CACHED_SETTING(UpdateInterval, interval); PhApplyUpdateInterval(interval); CheckMenuRadioItem( PhMainWndMenuHandle, @@ -1765,6 +1770,7 @@ VOID PhpInitialLoadSettings() NotifyIconNotifyMask = PhGetIntegerSetting(L"IconNotifyMask"); + PhLoadTreeListColumnsFromSetting(L"ProcessTreeListColumns", ProcessTreeListHandle); PhLoadListViewColumnsFromSetting(L"ServiceListViewColumns", ServiceListViewHandle); PhLoadListViewColumnsFromSetting(L"NetworkListViewColumns", NetworkListViewHandle); } @@ -1807,6 +1813,7 @@ VOID PhpSaveAllSettings() WINDOWPLACEMENT placement = { sizeof(placement) }; PH_RECTANGLE windowRectangle; + PhSaveTreeListColumnsToSetting(L"ProcessTreeListColumns", ProcessTreeListHandle); PhSaveListViewColumnsToSetting(L"ServiceListViewColumns", ServiceListViewHandle); PhSaveListViewColumnsToSetting(L"NetworkListViewColumns", NetworkListViewHandle); diff --git a/ProcessHacker/proctree.c b/ProcessHacker/proctree.c index 97c6e28ae..f215600fb 100644 --- a/ProcessHacker/proctree.c +++ b/ProcessHacker/proctree.c @@ -87,8 +87,10 @@ VOID PhInitializeProcessTreeList( PhAddTreeListColumn(hwnd, PHTLC_NAME, TRUE, L"Name", 200, PH_ALIGN_LEFT, 0, 0); PhAddTreeListColumn(hwnd, PHTLC_PID, TRUE, L"PID", 50, PH_ALIGN_RIGHT, 1, DT_RIGHT); PhAddTreeListColumn(hwnd, PHTLC_CPU, TRUE, L"CPU", 45, PH_ALIGN_RIGHT, 2, DT_RIGHT); - PhAddTreeListColumn(hwnd, PHTLC_PVTMEMORY, TRUE, L"Pvt. Memory", 70, PH_ALIGN_RIGHT, 3, DT_RIGHT); - PhAddTreeListColumn(hwnd, PHTLC_USERNAME, TRUE, L"User Name", 140, PH_ALIGN_LEFT, 4, 0); + PhAddTreeListColumn(hwnd, PHTLC_IOTOTAL, TRUE, L"I/O Total", 70, PH_ALIGN_RIGHT, 3, DT_RIGHT); + PhAddTreeListColumn(hwnd, PHTLC_PVTMEMORY, TRUE, L"Pvt. Memory", 70, PH_ALIGN_RIGHT, 4, DT_RIGHT); + PhAddTreeListColumn(hwnd, PHTLC_USERNAME, TRUE, L"User Name", 140, PH_ALIGN_LEFT, 5, 0); + PhAddTreeListColumn(hwnd, PHTLC_DESCRIPTION, TRUE, L"Description", 180, PH_ALIGN_LEFT, 6, 0); TreeList_SetTriState(hwnd, TRUE); TreeList_SetSort(hwnd, 0, NoSortOrder); @@ -264,9 +266,11 @@ VOID PhpRemoveProcessNode( PhDereferenceObject(ProcessNode->Children); - if (ProcessNode->PrivateMemoryText) PhDereferenceObject(ProcessNode->PrivateMemoryText); if (ProcessNode->TooltipText) PhDereferenceObject(ProcessNode->TooltipText); + if (ProcessNode->IoTotalText) PhDereferenceObject(ProcessNode->IoTotalText); + if (ProcessNode->PrivateMemoryText) PhDereferenceObject(ProcessNode->PrivateMemoryText); + PhDereferenceObject(ProcessNode->ProcessItem); PhFree(ProcessNode); @@ -412,6 +416,15 @@ BEGIN_SORT_FUNCTION(Cpu) } END_SORT_FUNCTION +BEGIN_SORT_FUNCTION(IoTotal) +{ + sortResult = uint64cmp( + processItem1->IoReadDelta.Delta + processItem1->IoWriteDelta.Delta + processItem1->IoOtherDelta.Delta, + processItem2->IoReadDelta.Delta + processItem2->IoWriteDelta.Delta + processItem2->IoOtherDelta.Delta + ); +} +END_SORT_FUNCTION + BEGIN_SORT_FUNCTION(PvtMemory) { sortResult = uintptrcmp(processItem1->VmCounters.PrivateUsage, processItem2->VmCounters.PrivateUsage); @@ -424,6 +437,16 @@ BEGIN_SORT_FUNCTION(UserName) } END_SORT_FUNCTION +BEGIN_SORT_FUNCTION(Description) +{ + sortResult = PhStringCompareWithNull( + processItem1->VersionInfo.FileDescription, + processItem2->VersionInfo.FileDescription, + TRUE + ); +} +END_SORT_FUNCTION + BOOLEAN NTAPI PhpProcessTreeListCallback( __in HWND hwnd, __in PH_TREELIST_MESSAGE Message, @@ -464,8 +487,10 @@ BOOLEAN NTAPI PhpProcessTreeListCallback( SORT_FUNCTION(Name), SORT_FUNCTION(Pid), SORT_FUNCTION(Cpu), + SORT_FUNCTION(IoTotal), SORT_FUNCTION(PvtMemory), - SORT_FUNCTION(UserName) + SORT_FUNCTION(UserName), + SORT_FUNCTION(Description) }; int (__cdecl *sortFunction)(const void *, const void *); @@ -515,14 +540,35 @@ BOOLEAN NTAPI PhpProcessTreeListCallback( case PHTLC_CPU: PhInitializeStringRef(&getNodeText->Text, processItem->CpuUsageString); break; + case PHTLC_IOTOTAL: + { + ULONG64 number; + + number = processItem->IoReadDelta.Delta + processItem->IoWriteDelta.Delta + processItem->IoOtherDelta.Delta; + number *= 1000; + number /= PhCsUpdateInterval; + + if (number != 0) + { + PhSwapReference2(&node->IoTotalText, PhConcatStrings2(PhaFormatSize(number, -1)->Buffer, L"/s")); + getNodeText->Text = node->IoTotalText->sr; + } + else + { + PhInitializeEmptyStringRef(&getNodeText->Text); + } + } + break; case PHTLC_PVTMEMORY: - if (node->PrivateMemoryText) PhDereferenceObject(node->PrivateMemoryText); - node->PrivateMemoryText = PhFormatSize(processItem->VmCounters.PrivateUsage, -1); + PhSwapReference2(&node->PrivateMemoryText, PhFormatSize(processItem->VmCounters.PrivateUsage, -1)); getNodeText->Text = node->PrivateMemoryText->sr; break; case PHTLC_USERNAME: getNodeText->Text = PhGetStringRefOrEmpty(processItem->UserName); break; + case PHTLC_DESCRIPTION: + getNodeText->Text = PhGetStringRefOrEmpty(processItem->VersionInfo.FileDescription); + break; default: return FALSE; } diff --git a/ProcessHacker/settings.c b/ProcessHacker/settings.c index 56050f458..32dc64e00 100644 --- a/ProcessHacker/settings.c +++ b/ProcessHacker/settings.c @@ -64,6 +64,7 @@ VOID PhSettingsInitialization() PhpAddStringSetting(L"ModuleListViewColumns", L""); PhpAddStringSetting(L"NetworkListViewColumns", L""); PhpAddStringSetting(L"ProcessServiceListViewColumns", L""); + PhpAddStringSetting(L"ProcessTreeListColumns", L""); PhpAddStringSetting(L"ProcPropPage", L"General"); PhpAddIntegerPairSetting(L"ProcPropPosition", L"200,200"); PhpAddIntegerPairSetting(L"ProcPropSize", L"460,580"); @@ -127,6 +128,8 @@ VOID PhUpdateCachedSettings() { #define UPDATE_INTEGER_CS(Name) (PhCs##Name = PhGetIntegerSetting(L#Name)) + UPDATE_INTEGER_CS(UpdateInterval); + UPDATE_INTEGER_CS(ColorNew); UPDATE_INTEGER_CS(ColorRemoved); UPDATE_INTEGER_CS(UseColorOwnProcesses); diff --git a/ProcessHacker/support.c b/ProcessHacker/support.c index 411d2b748..e4150ac06 100644 --- a/ProcessHacker/support.c +++ b/ProcessHacker/support.c @@ -505,3 +505,27 @@ VOID PhSaveListViewColumnsToSetting( PhSetStringSetting2(Name, &string->sr); PhDereferenceObject(string); } + +VOID PhLoadTreeListColumnsFromSetting( + __in PWSTR Name, + __in HWND TreeListHandle + ) +{ + PPH_STRING string; + + string = PhGetStringSetting(Name); + PhLoadTreeListColumnSettings(TreeListHandle, string); + PhDereferenceObject(string); +} + +VOID PhSaveTreeListColumnsToSetting( + __in PWSTR Name, + __in HWND TreeListHandle + ) +{ + PPH_STRING string; + + string = PhSaveTreeListColumnSettings(TreeListHandle); + PhSetStringSetting2(Name, &string->sr); + PhDereferenceObject(string); +} diff --git a/phlib/include/treelist.h b/phlib/include/treelist.h index ea5cb44c2..f0540c5dd 100644 --- a/phlib/include/treelist.h +++ b/phlib/include/treelist.h @@ -202,6 +202,7 @@ typedef struct _PH_TREELIST_MOUSE_EVENT #define TLM_ENSUREVISIBLE (WM_APP + 1217) #define TLM_SETSELECTIONMARK (WM_APP + 1218) #define TLM_SETSTATEALL (WM_APP + 1219) +#define TLM_GETCOLUMNCOUNT (WM_APP + 1220) #define TreeList_SetCallback(hWnd, Callback) \ SendMessage((hWnd), TLM_SETCALLBACK, 0, (LPARAM)(Callback)) @@ -230,8 +231,8 @@ typedef struct _PH_TREELIST_MOUSE_EVENT #define TLCM_ALIGNMENT 0x8 #define TLCM_DISPLAYINDEX 0x10 -#define TreeList_GetColumn(hWnd, Column, Mask) \ - SendMessage((hWnd), TLM_GETCOLUMN, (WPARAM)(Mask), (LPARAM)(Column)) +#define TreeList_GetColumn(hWnd, Column) \ + SendMessage((hWnd), TLM_GETCOLUMN, 0, (LPARAM)(Column)) #define TreeList_SetColumn(hWnd, Column, Mask) \ SendMessage((hWnd), TLM_SETCOLUMN, (WPARAM)(Mask), (LPARAM)(Column)) @@ -266,6 +267,9 @@ typedef struct _PH_TREELIST_MOUSE_EVENT #define TreeList_SetStateAll(hWnd, State, Mask) \ SendMessage((hWnd), TLM_SETSTATEALL, (WPARAM)(State), (LPARAM)(Mask)) +#define TreeList_GetColumnCount(hWnd) \ + ((ULONG)SendMessage((hWnd), TLM_GETCOLUMNCOUNT, 0, 0)) + BOOLEAN PhTreeListInitialization(); HWND PhCreateTreeListControl( @@ -303,6 +307,15 @@ BOOLEAN PhAddTreeListColumn( __in ULONG TextFlags ); +BOOLEAN PhLoadTreeListColumnSettings( + __in HWND TreeListHandle, + __in PPH_STRING Settings + ); + +PPH_STRING PhSaveTreeListColumnSettings( + __in HWND TreeListHandle + ); + __callback BOOLEAN NTAPI PhTreeListNullCallback( __in HWND hwnd, __in PH_TREELIST_MESSAGE Message, diff --git a/phlib/treelist.c b/phlib/treelist.c index e062977db..7899739b5 100644 --- a/phlib/treelist.c +++ b/phlib/treelist.c @@ -714,6 +714,38 @@ LRESULT CALLBACK PhpTreeListWndProc( PhpRefreshColumnsViewX(context); } return TRUE; + case TLM_REMOVECOLUMN: + { + PPH_TREELIST_COLUMN column = (PPH_TREELIST_COLUMN)lParam; + PPH_TREELIST_COLUMN realColumn; + + if ( + column->Id >= context->AllocatedColumns || + !(realColumn = context->Columns[column->Id]) + ) + return FALSE; + + PhpDeleteColumn(context, realColumn); + PhpRefreshColumnsViewX(context); + context->Columns[column->Id] = NULL; + + context->NumberOfColumns--; + } + return TRUE; + case TLM_GETCOLUMN: + { + PPH_TREELIST_COLUMN column = (PPH_TREELIST_COLUMN)lParam; + PPH_TREELIST_COLUMN realColumn; + + if ( + column->Id >= context->AllocatedColumns || + !(realColumn = context->Columns[column->Id]) + ) + return FALSE; + + memcpy(column, realColumn, sizeof(PH_TREELIST_COLUMN)); + } + return TRUE; case TLM_SETCOLUMN: { ULONG mask = (ULONG)wParam; @@ -732,11 +764,9 @@ LRESULT CALLBACK PhpTreeListWndProc( { if (column->Visible) { - column->DisplayIndex = MAXINT; - realColumn->s.ViewIndex = PhpInsertColumn(context, column); - // Other attributes already set by insertion. - PhpRefreshColumnsViewX(context); - return TRUE; + realColumn->DisplayIndex = MAXINT; + realColumn->s.ViewIndex = PhpInsertColumn(context, realColumn); + // Set other attributes below. } else { @@ -783,24 +813,6 @@ LRESULT CALLBACK PhpTreeListWndProc( } } return TRUE; - case TLM_REMOVECOLUMN: - { - PPH_TREELIST_COLUMN column = (PPH_TREELIST_COLUMN)lParam; - PPH_TREELIST_COLUMN realColumn; - - if ( - column->Id >= context->AllocatedColumns || - !(realColumn = context->Columns[column->Id]) - ) - return FALSE; - - PhpDeleteColumn(context, realColumn); - PhpRefreshColumnsViewX(context); - context->Columns[column->Id] = NULL; - - context->NumberOfColumns--; - } - return TRUE; case TLM_SETPLUSMINUS: { HBITMAP plusBitmap = (HBITMAP)wParam; @@ -915,6 +927,8 @@ LRESULT CALLBACK PhpTreeListWndProc( ListView_SetItemState(context->ListViewHandle, -1, (UINT)wParam, (UINT)lParam); } return TRUE; + case TLM_GETCOLUMNCOUNT: + return context->NumberOfColumns; } return DefWindowProc(hwnd, uMsg, wParam, lParam); @@ -1623,6 +1637,8 @@ static INT PhpInsertColumn( lvColumn.iSubItem = Column->Id; lvColumn.iOrder = Column->DisplayIndex; + Column->Visible = TRUE; + return ListView_InsertColumn(Context->ListViewHandle, MAXINT, &lvColumn); } @@ -1631,6 +1647,7 @@ static VOID PhpDeleteColumn( __inout PPH_TREELIST_COLUMN Column ) { + Column->Visible = FALSE; ListView_DeleteColumn(Context->ListViewHandle, Column->s.ViewIndex); PhpRefreshColumns(Context); } @@ -1782,6 +1799,186 @@ BOOLEAN PhAddTreeListColumn( return !!TreeList_AddColumn(hwnd, &column); } +BOOLEAN PhLoadTreeListColumnSettings( + __in HWND TreeListHandle, + __in PPH_STRING Settings + ) +{ + BOOLEAN result = FALSE; + ULONG i; + ULONG count; + ULONG total; + ULONG length; + ULONG indexOfComma; + ULONG indexOfComma2; + ULONG indexOfPipe; + PH_STRINGREF stringRef; + ULONG64 integer; + PPH_HASHTABLE columnHashtable; + PPH_KEY_VALUE_PAIR pair; + + // This is one of those functions where you wish you could use C#. + + if (Settings->Length == 0) + return FALSE; + + columnHashtable = PhCreateSimpleHashtable(20); + + i = 0; + length = (ULONG)Settings->Length / 2; + + while (i < length) + { + PPH_TREELIST_COLUMN column; + ULONG id; + ULONG displayIndex; + ULONG width; + + indexOfComma = PhStringIndexOfChar(Settings, i, ','); + + if (indexOfComma == -1) + goto CleanupExit; + + indexOfPipe = PhStringIndexOfChar(Settings, i, '|'); + + if (indexOfPipe == -1) // last pair in string + indexOfPipe = Settings->Length / 2; + + indexOfComma2 = PhStringIndexOfChar(Settings, indexOfComma + 1, ','); + + if (indexOfComma2 == -1 || indexOfComma2 > indexOfPipe) + goto CleanupExit; + + // Id + + stringRef.Buffer = &Settings->Buffer[i]; + stringRef.Length = (USHORT)((indexOfComma - i) * 2); + + if (!PhStringToInteger64(&stringRef, 10, &integer)) + goto CleanupExit; + + id = (ULONG)integer; + + // Display Index + + stringRef.Buffer = &Settings->Buffer[indexOfComma + 1]; + stringRef.Length = (USHORT)((indexOfComma2 - indexOfComma - 1) * 2); + + if (!PhStringToInteger64(&stringRef, 10, &integer)) + goto CleanupExit; + + displayIndex = (ULONG)integer; + + // Width + + stringRef.Buffer = &Settings->Buffer[indexOfComma2 + 1]; + stringRef.Length = (USHORT)((indexOfPipe - indexOfComma2 - 1) * 2); + + if (!PhStringToInteger64(&stringRef, 10, &integer)) + goto CleanupExit; + + width = (ULONG)integer; + + column = PhAllocate(sizeof(PH_TREELIST_COLUMN)); + column->Id = id; + column->DisplayIndex = displayIndex; + column->Width = width; + PhAddSimpleHashtableItem(columnHashtable, (PVOID)column->Id, column); + + i = indexOfPipe + 1; + } + + // Hide all the columns. + i = 0; + count = 0; + total = TreeList_GetColumnCount(TreeListHandle); + + while (count < total) + { + PH_TREELIST_COLUMN setColumn; + PPH_TREELIST_COLUMN *columnPtr; + + setColumn.Id = i; + + columnPtr = (PPH_TREELIST_COLUMN *)PhGetSimpleHashtableItem(columnHashtable, (PVOID)i); + + if (columnPtr) + { + setColumn.Width = (*columnPtr)->Width; + setColumn.DisplayIndex = (*columnPtr)->DisplayIndex; + setColumn.Visible = TRUE; + TreeList_SetColumn(TreeListHandle, &setColumn, TLCM_VISIBLE | TLCM_WIDTH | TLCM_DISPLAYINDEX); + } + else + { + setColumn.Visible = FALSE; + TreeList_SetColumn(TreeListHandle, &setColumn, TLCM_VISIBLE); + } + + i++; + count++; + } + + result = TRUE; + +CleanupExit: + + i = 0; + + while (PhEnumHashtable(columnHashtable, &pair, &i)) + PhFree(pair->Value); + + PhDereferenceObject(columnHashtable); + + return result; +} + +PPH_STRING PhSaveTreeListColumnSettings( + __in HWND TreeListHandle + ) +{ + PH_STRING_BUILDER stringBuilder; + PPH_STRING string; + ULONG i = 0; + ULONG count = 0; + ULONG total; + PH_TREELIST_COLUMN column; + + total = TreeList_GetColumnCount(TreeListHandle); + + PhInitializeStringBuilder(&stringBuilder, 20); + + while (count < total) + { + column.Id = i; + + if ( + TreeList_GetColumn(TreeListHandle, &column) && + column.Visible + ) + { + PhStringBuilderAppendFormat( + &stringBuilder, + L"%u,%u,%u|", + i, + column.DisplayIndex, + column.Width + ); + } + + i++; + count++; + } + + if (stringBuilder.String->Length != 0) + PhStringBuilderRemove(&stringBuilder, stringBuilder.String->Length / 2 - 1, 1); + + string = PhReferenceStringBuilderString(&stringBuilder); + PhDeleteStringBuilder(&stringBuilder); + + return string; +} + __callback BOOLEAN NTAPI PhTreeListNullCallback( __in HWND hwnd, __in PH_TREELIST_MESSAGE Message,