thumbnail extraction win32com -how?
guy at NOSPAM.r-e-d.co.nz
Mon Sep 13 14:15:43 CEST 2004
I revist this every now and then and are still no closer to getting it to work.
I want to extract the thumbnail from a file on windows using either win32com or
ctypes. As described in this link:
Has anyone implemented this? Or can explain how to do this. Basically it
involves calling IExtractImage from shell32. But I'm not sure how to get the
file object or access IExtractImage.
This is what I have so far (which doesn't work):
Dispatch = win32com.client.Dispatch
objShell = Dispatch("Shell.Application");
objFolder = objShell.Namespace(0);
localPidl = objFolder.ParseName('path\filename');
uio = objShell.GetUIObjectOf(NULL, 1, localPidl,IID_IExtractImage,NULL,IExtract)
Based on the following C code:
HBITMAP ExtractThumb(LPSHELLFOLDER psfFolder, LPCITEMIDLIST localPidl,
const SIZE* prgSize, DWORD dwRecClrDepth)
LPEXTRACTIMAGE pIExtract = NULL;
hr = psfFolder->GetUIObjectOf(NULL, 1, &localPidl, IID_IExtractImage,
if(NULL == pIExtract) // early shell version, thumbs not supported
DWORD dwPriority = 0; // IEI_PRIORITY_NORMAL is defined nowhere!
DWORD dwFlags = IEIFLAG_SCREEN;
HBITMAP hBmpImage = NULL;
hr = pIExtract->GetLocation(wszPathBuffer, MAX_PATH, &dwPriority,
prgSize, dwRecClrDepth, &dwFlags);
// even if we've got shell v4.70+, not all files support thumbnails
if(NOERROR == hr) hr = pIExtract->Extract(&hBmpImage);
return hBmpImage; // callers should DeleteObject this handle after use
More information about the Python-list