如何仅用ctypes通过SHOpenFolderAndSelectItems在资源管理器中选中文件?
在Python中实现资源管理器选中指定文件
基于pywin32的实现方式
借助pywin32库可以快速实现该功能,代码示例如下:
from win32com.shell import shell def showFilesInExplorer(folder, files): folder_pidl = shell.SHILCreateFromPath(folder, 0)[0] files_pidl = [shell.SHILCreateFromPath(f, 0)[0] for f in files] shell.SHOpenFolderAndSelectItems(folder_pidl, files_pidl, 0)
无依赖的ctypes实现思路
如果希望避免依赖pywin32库,理论上可以仅通过ctypes直接调用Windows系统API来完成同样的功能,无需引入第三方库。
内容的提问来源于stack exchange,提问作者arenasys
相关产品推荐
相关产品推荐

