I got this working for Win 10, but Win 11 doesn't have the "Address: " text so I can't detect folders on that OS.

Code: Select all
; https://www.purebasic.fr/english/viewtopic.php?p=572887#p572887
Global NewMap hWnd()
Procedure EnumChildProc(hWnd, lParam)
If Not FindMapElement(hWnd(), Str(hWnd))
GetWindowThreadProcessId_(hWnd, @PID)
WindowTitle.s = Space(999)
GetWindowText_(hWnd, @WindowTitle, 999)
lpClassName.s = Space(999)
GetClassName_(hWnd, @lpClassName, 999)
;If FindString(WindowTitle, "Address: ") And lpClassName="ToolbarWindow32" ; Shows folder paths on Win 10. :)
If lpClassName="ShellTabWindowClass" ; Shows folder NAMES for Win 11's tabbed folders, but not their paths. :(
AddGadgetItem(0, -1, "PID: " + Right("000" + Str(PID), 4) + " Window: " + Right("0000" + Hex(hWnd, #PB_Long), 8) + " " + #DQUOTE$ + WindowTitle + #DQUOTE$ + " " + lpClassName, 0, lParam + 1)
EndIf
hWnd(Str(hWnd))
EndIf
EnumChildWindows_(hWnd, @EnumChildProc(), lParam + 1)
ProcedureReturn #True
EndProcedure
If OpenWindow(0, 0, 0, 1000, 800, "Open Folders", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TreeGadget(0, 10, 10, 980, 780, #PB_Tree_AlwaysShowSelection)
EnumChildWindows_(GetDesktopWindow_(), @EnumChildProc(), 0)
SetWindowTitle(0, "Enumerated Folders: " + Str(CountGadgetItems(0)))
SetGadgetItemState(0, 0, #PB_Tree_Expanded)
tvRoot = SendMessage_(GadgetID(0), #TVM_GETNEXTITEM, #TVGN_ROOT, 0)
SendMessage_(GadgetID(0), #TVM_SORTCHILDREN, #True, tvRoot)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf