[pywin32-checkins] pywin32/com/win32comext/shell/demos walk_shell_folders.py,NONE,1.1
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-09-27 01:46:42
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25137 Added Files: walk_shell_folders.py Log Message: A little sample showing how to walk IShellFolder interfaces. --- NEW FILE: walk_shell_folders.py --- # A little sample that walks from the desktop into child # items. from win32com.shell import shell, shellcon def walk(folder, depth=2, indent=""): try: pidls = folder.EnumObjects(0, shellcon.SHCONTF_FOLDERS) except shell.error: # no items return for pidl in pidls: dn = folder.GetDisplayNameOf(pidl, shellcon.SHGDN_NORMAL) print indent, dn if depth: try: child = folder.BindToObject(pidl, None, shell.IID_IShellFolder) except shell.error: pass else: walk(child, depth-1, indent+" ") walk(shell.SHGetDesktopFolder()) |