目标是在尽可能短的时间内从windows上的选定文件夹中获取文件缩略图
Imagemagick和其他工具每次都会打开文件,因此它们可能不是最有效的。Windows中的内置机制有可能将缩略图放在缓存中,这在理论上可以大大提高速度
从How to get thumbnail of file using the Windows API?(answer)开始,道路变得清晰,但存在很多问题:
在win32com.shell.shell中找不到该IID,因此它们是手动提供的
IThumbnailProvider,IShellItem::BindToHandler method:已修复,但现在错误如下所示:
# str(shell.IID_IShellItem) == '{43826D1E-E718-42EE-BC55-A1E261C37BFE}'
# str(shell.BHID_ThumbnailHandler) == '{7B2E650A-8E20-4F4A-B09E-6597AFC72FB0}'
item = shell.SHCreateItemFromParsingName(r'd:\some.png', None, str(shell.IID_IShellItem)) # str() is works
IID_IThumbnailProvider = '{e357fccd-a995-4576-b01f-234630154e96}'
provider = item.BindToHandler(None, shell.BHID_ThumbnailHandler, IID_IThumbnailProvider) # error
> TypeError: 'There is no interface object registered that supports this IID'
IShellItemImageFactory:怀疑IID的用法有误,但从下面的answer来看,它应该可以工作:
IID_IShellItemImageFactory = '{bcc18b79-ba16-442f-80c4-8a59c30c463b}'
item = shell.SHCreateItemFromParsingName(r'd:\some.png', None, IID_IShellItemImageFactory) # error
> TypeError: 'There is no interface object registered that supports this IID'
在不学习整个winapi的情况下,了解如何在所有这些环境中游泳将是非常棒的
提前谢谢
Windows 10(20H2)、Python 3.9.5、PyWin32 301
更新:找到关于PyWin32(pythoncom.CoCreateInstance can't create IZoneIdentifier; the interface is missing from registry too despite being documented in MSDN)的答案。简而言之,这些接口没有实现。审核人:
> import pythoncom
> pythoncom.InterfaceNames
所以。。还有两个问题。有没有不使用PyWin32就可以获得缩略图的选项?例如,通过ctypes。怎么做
目前没有回答
相关问题 更多 >
编程相关推荐