Pywin32替代或将PyIDL转换为PIDL的方法

时间:2015-03-27 17:12:35

标签: python windows ctypes pywin32 activepython

显然我已经发现了a bug in pywin32。现在我无法将win32com.shell.shell.SHGetFileInfo函数与win32com.shell.shellcon.SHGFI_PIDL标志一起使用。

我想要做的是枚举桌面图标(所有这些图标,包括虚拟图标)并自己获取图标(图像)。我试图这样做(在我知道错误之前)使用类似的东西:

from win32com.shell import shell, shellcon
desktop = shell.SHGetDesktopFolder()
enum = desktop.EnumObjects(None, shellcon.SHCONTF_FOLDERS | shellcon.SHCONTF_NONFOLDERS)
for pidl in enum:
    shell_info = shell.SHGetFileInfo(desktop_pidl, 0, shellcon.SHGFI_PIDL | shellcon.SHGFI_SYSICONINDEX | shellcon.SHGFI_ICON | shellcon.SHGFI_DISPLAYNAME)

那么如果没有shell.SHGetFileInfo PIDL,我怎么能这样做呢?使用ctypes的问题是enum包含特定于pywin32的PyIDL。有没有办法将PyIDL转换为可以与ctypes一起使用的常规PIDL?或者有没有办法完全没有PyIDL?

在最糟糕的情况下,我可以使用ctypes来完成所有这些(包括SHGetDesktopFolderEnumObjects),但这真的很长,有点像重新发明轮子。

谢谢!

0 个答案:

没有答案