BExplorer.Shell.Interop.ShellThumbnail.ExtractAndDrawThumbnail C# (CSharp) Method

ExtractAndDrawThumbnail() public method

public ExtractAndDrawThumbnail ( IntPtr hdc, uint iconSize, WTS_CACHEFLAGS &flags, User32 iconBounds, bool &retrieved, bool isHidden, bool isRefresh = false ) : HResult
hdc System.IntPtr
iconSize uint
flags WTS_CACHEFLAGS
iconBounds User32
retrieved bool
isHidden bool
isRefresh bool
return HResult
        public HResult ExtractAndDrawThumbnail(IntPtr hdc, uint iconSize, out WTS_CACHEFLAGS flags, User32.RECT iconBounds, out bool retrieved, bool isHidden, bool isRefresh = false)
        {
            HResult res = HResult.S_OK;
            ISharedBitmap bmp = null;
            flags = WTS_CACHEFLAGS.WTS_DEFAULT;
            WTS_THUMBNAILID thumbId = new WTS_THUMBNAILID();
            try
            {
                retrieved = false;
                res = ThumbnailCache.GetThumbnail(this._Item.ComInterface, iconSize, isRefresh ? (WTS_FLAGS.WTS_FORCEEXTRACTION | WTS_FLAGS.WTS_SCALETOREQUESTEDSIZE) : (WTS_FLAGS.WTS_INCACHEONLY | WTS_FLAGS.WTS_SCALETOREQUESTEDSIZE), out bmp, flags, thumbId);
                IntPtr hBitmap = IntPtr.Zero;
                if (bmp != null)
                {
                    bmp.GetSharedBitmap(out hBitmap);
                    retrieved = true;

                    int width;
                    int height;
                    Gdi32.ConvertPixelByPixel(hBitmap, out width, out height);
                    Gdi32.NativeDraw(hdc, hBitmap, iconBounds.Left + (iconBounds.Right - iconBounds.Left - width) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - height) / 2, width, height, isHidden);
                    Gdi32.DeleteObject(hBitmap);
                }
            }
            finally
            {
                if (bmp != null) Marshal.ReleaseComObject(bmp);
            }
            return res;
        }