Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sunny127 opened this issue Mar 2, 2019 · 3 comments

Comments

@sunny127
Copy link

sunny127 commented Mar 2, 2019

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
Copy link

can send me a compiled version?

@TheOddball
Copy link

Do this as a Pull Request not an issue.

@bruhov
Copy link
Owner

bruhov commented Dec 18, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants