When I try to extract thumbnail of any document which has thumbnail view in windows explorer, it succeeds and displays the image.
Whereas for documents which does not have thumbnail view (eg. empty folder)which has icon as its thumbnail view thorws exception.
Is there any way to extract that icon image as thumbnail view without throwing exception.
My code is
item.GetUIObjectOf(IntPtr.Zero, 1, ref pidl, ref iidExtractImage, out prgf, ref iunk);
extractImage = (IExtractImage)iunk;
if (extractImage != null)
{
//Got an IExtractImage object!
SIZE sz = new SIZE();
sz.cx = desiredSize.Width;
sz.cy = desiredSize.Height;
StringBuilder location = new StringBuilder(260, 260);
int priority = 0;
int requestedColourDepth = 32;
EIEIFLAG flags = EIEIFLAG.IEIFLAG_ASPECT | EIEIFLAG.IEIFLAG_SCREEN;
int uFlags = (int)flags;
extractImage.GetLocation(location, location.Capacity, ref priority, ref sz, requestedColourDepth, ref uFlags);
extractImage.Extract(out hBmp);
}