Skip to content

Commit cc57027

Browse files
committed
Fix get thumbnail exception
1 parent 0893134 commit cc57027

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public class WindowsThumbnailProvider
3131

3232
private static readonly Guid GUID_IShellItem = typeof(IShellItem).GUID;
3333

34-
private static readonly HRESULT S_ExtractionFailed = (HRESULT)0x8004B200;
35-
3634
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
3735
{
3836
HBITMAP hBitmap = GetHBitmap(Path.GetFullPath(fileName), width, height, options);
@@ -79,7 +77,12 @@ private static unsafe HBITMAP GetHBitmap(string fileName, int width, int height,
7977
{
8078
imageFactory.GetImage(size, (SIIGBF)options, &hBitmap);
8179
}
82-
catch (COMException ex) when (ex.HResult == S_ExtractionFailed && options == ThumbnailOptions.ThumbnailOnly)
80+
catch (COMException)
81+
{
82+
// Fallback to IconOnly if ThumbnailOnly fails
83+
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
84+
}
85+
catch (FileNotFoundException)
8386
{
8487
// Fallback to IconOnly if ThumbnailOnly fails
8588
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);

0 commit comments

Comments
 (0)