| Server IP : 123.56.80.60 / Your IP : 216.73.216.78 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/python/Lib/site-packages/win32comext/shell/demos/ |
Upload File : |
# A couple of samples using SHBrowseForFolder
import sys, os
from win32com.shell import shell, shellcon
import win32gui
# A callback procedure - called by SHBrowseForFolder
def BrowseCallbackProc(hwnd, msg, lp, data):
if msg== shellcon.BFFM_INITIALIZED:
win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
elif msg == shellcon.BFFM_SELCHANGED:
# Set the status text of the
# For this message, 'lp' is the address of the PIDL.
pidl = shell.AddressAsPIDL(lp)
try:
path = shell.SHGetPathFromIDList(pidl)
win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
except shell.error:
# No path for this PIDL
pass
if __name__=='__main__':
# Demonstrate a dialog with the cwd selected as the default - this
# must be done via a callback function.
flags = shellcon.BIF_STATUSTEXT
shell.SHBrowseForFolder(0, # parent HWND
None, # root PIDL.
"Default of %s" % os.getcwd(), # title
flags, # flags
BrowseCallbackProc, # callback function
os.getcwd() # 'data' param for the callback
)
# Browse from this directory down only.
# Get the PIDL for the cwd.
desktop = shell.SHGetDesktopFolder()
cb, pidl, extra = desktop.ParseDisplayName(0, None, os.getcwd())
shell.SHBrowseForFolder(0, # parent HWND
pidl, # root PIDL.
"From %s down only" % os.getcwd(), # title
)