Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
}
Posted

1 solution

Can't you just catch the exception and handle it accordingly? (e.g. use the system icon instead)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900