[python-win32] How to use IExtractImage in python

Steven James steven.james at gmail.com
Wed Apr 18 15:15:29 CEST 2007


I am attempting to add a simple thumbnail preview in a wxpython app I'm
putting together. IExtractImage seems to be the way to access the thumbnails
that Windows Explorer uses.

(I can't use PIL or similar because I'm previewing AutoCAD .dwg files).

I am adapting some Delphi COM code (from
here<http://www.delphi3000.com/articles/article_3806.asp?SK=>)
as follows--i've removed the Malloc and other unnecessary statements:

--begin delphi code--

if NOERROR = SHGetDesktopFolder(DesktopFolder) then
 DesktopFolder.ParseDisplayName(0, nil, 'C:\WINNT', Eaten,
    ItemIDList, Attributes);
  DesktopFolder.BindToObject(ItemIDList, nil, IShellFolder,
    TargetFolder);
  TargetFolder.ParseDisplayName(0, nil, 'delphi_wallpaper1024.bmp', Eaten,
    ItemIDList, Attributes);
  TargetFolder.GetUIObjectOf(0, 1, ItemIDList, IExtractImage,
    nil, XtractImg);
  Malloc.Free(ItemIDList);

--end delphi code--


--begin python adaption--

        testPath = "C:\\"
        testFileName = "test.dwg" #also have tried test.bmp, test.png
        iSHFolder = shell.SHGetDesktopFolder()
        eaten, idList, attr = iSHFolder.ParseDisplayName(0, None, testPath)
        targetFolder = iSHFolder.BindToObject(idList, None,
shell.IID_IShellFolder)
        eaten, targetIdList, attr = targetFolder.ParseDisplayName(0, None,
testFileName)
        pprint ([eaten, targetIdList, attr])
        extractImage = targetFolder.GetUIObjectOf(0, [targetIdList],
                pythoncom.MakeIID
('{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}'),0)

--end python adaptation--

The python code fails on the last statement, throwing the following
exception:

TypeError: There is no interface object registered that supports this IID

Any ideas on how to use this interface in python? I have googled for hours.

Thanks,
Steven James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070418/971240cc/attachment.html 


More information about the Python-win32 mailing list