bruhov / WinThumbsPreloader

WinThumbsPreloader is a simple open source tool for preloading thumbnails in Windows Explorer.
MIT License
589 stars 38 forks source link

The app kept crashing on my PC. I changed the following function and it now very stable. #3

Open sunny127 opened 5 years ago

sunny127 commented 5 years ago

Hi, the app kept crashing on my PC. I changed the following function and it now very stable. using System.IO; `public void PreloadThumbnail(string filePath) { IShellItem shellItem = null; ISharedBitmap bmp = null; WTS_CACHEFLAGS cFlags; WTS_THUMBNAILID bmpId;

        FileAttributes attr = File.GetAttributes(filePath);

        if (!attr.HasFlag(FileAttributes.Directory))
        {
            try
            {
                SHCreateItemFromParsingName(filePath, IntPtr.Zero, iIdIShellItem, out shellItem);

                //TBCache.GetThumbnail(shellItem, 128, WTS_FLAGS.WTS_EXTRACTINPROC, out bmp, out cFlags, out bmpId);
                TBCache.GetThumbnail(shellItem, 128, WTS_FLAGS.WTS_EXTRACT, out bmp, out cFlags, out bmpId);
            }
            catch (Exception)
            {
                //Do nothing
            }
        }
        if (bmp != null) Marshal.ReleaseComObject(bmp);
        if (shellItem != null)  Marshal.ReleaseComObject(shellItem);
        bmp = null;
        shellItem = null;
    }`
federcap commented 4 years ago

can send me a compiled version?

TheOddball commented 4 years ago

Do this as a Pull Request not an issue.

bruhov commented 4 years ago

I experienced application crashes when I used WTS_EXTRACT. I can’t reproduce it now. Maybe the environment is different.

Also, why disable directory thumbnail preloading?