Reputation: 2773
So apparently I have uncovered a bug in pywin32. Now I can't use the win32com.shell.shell.SHGetFileInfo
function with win32com.shell.shellcon.SHGFI_PIDL
flag.
What I want to do is to enumerate the desktop icons (all of them, including the virtual ones) and get the icons themselves (the images). I was trying to do this (before I knew about the bug) using something like:
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)
So how can I do this without shell.SHGetFileInfo
with PIDL? The problem with using ctypes for just this is that enum
contains PyIDLs which are specific to pywin32. Is there a way to cast PyIDL to regular PIDL that I can use with ctypes? Or is there a way to do this without PyIDL entirely?
In the worst case I can use ctypes for all of this (including the SHGetDesktopFolder
and EnumObjects
) but that's really long and kinda feels like reinventing the wheel.
Thank you!
Upvotes: 1
Views: 1205