Hi,
It seems MSDN does not have sufficient documentation on IExtractImage (shell extension for generating custom thumbnail). So far, I already have the public class that will be registered as the thumbnail extension for a particular file extension (eg. ".abc"). This COM class implements IExtractImage and IPersistFile. So far, when I open Explorer and view thumbnails of .abc files, it runs as expected. But when I do a refresh, the thumbnails are gone, just white background. Also, when I right click or double click an .abc file, Explorer crashes.
This is the snippet of the extension class:
Another thing, the MSDN states that if the COM is compiled as free-threaded, the IRunnableTask interface must be implemented also. Question: How do I know my COM assembly is free-threaded? I can see that the assembly's threading model is registered as "Both", is this different from being a free-threaded? Why do the thumbnails disappear every time I hit refresh? And, if it is, what is the IID of IRunnableTask (couldn't find it from the SDK) ?
I hope someone can help me on this.
TIA![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
It seems MSDN does not have sufficient documentation on IExtractImage (shell extension for generating custom thumbnail). So far, I already have the public class that will be registered as the thumbnail extension for a particular file extension (eg. ".abc"). This COM class implements IExtractImage and IPersistFile. So far, when I open Explorer and view thumbnails of .abc files, it runs as expected. But when I do a refresh, the thumbnails are gone, just white background. Also, when I right click or double click an .abc file, Explorer crashes.
This is the snippet of the extension class:
Code:
[ComVisible(true)]
[Guid("D1C74EF1-C150-4c9c-BA73-453B8B1C0D90")]
[ClassInterface(ClassInterfaceType.None)]
public class Class1 : IExtractImage, IPersistFile
{
/* Section ommitted for brevity */
string tmpImgFile = "";
Size imgSize = Size.Empty;
public long GetLocation(out StringBuilder pszPathBuffer,
int cch, ref int pdwPriority, ref SIZE prgSize,
int dwRecClrDepth, ref int pdwFlags)
{
OutputDebugString("GetLocation");
pszPathBuffer = new StringBuilder();
//pszPathBuffer.Append(tmpImgFile);
imgSize = new Size(prgSize.cx, prgSize.cy);
// Windows XP (or even earlier) sets a null pointer for pdwPriority when selecting a file.
// MSDN does not explain any reasons.
// Vista, however, ignores this parameter.
if ((pdwFlags & IEIFLAG_ASYNC) > 0) return E_PENDING;
return NOERROR;
}
public int Extract(out IntPtr phBmpThumbnail)
{
OutputDebugString("Extract");
Bitmap tmpBmp = new Bitmap(imgSize.Width, imgSize.Height);
using (Graphics dcBmp = Graphics.FromImage(tmpBmp))
{
dcBmp.Clear(Color.Wheat);
using (Pen p = new Pen(Color.Black, 1.0f))
{
dcBmp.DrawLine(p, 0, 0, imgSize.Width, imgSize.Height);
}
}
phBmpThumbnail = tmpBmp.GetHbitmap();
return NOERROR;
}
I hope someone can help me on this.
TIA
![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)