diff --git a/Windows.Shell.Common/ShellObjects/ShellItem.cs b/Windows.Shell.Common/ShellObjects/ShellItem.cs
index 8f854b0f..6aa48646 100644
--- a/Windows.Shell.Common/ShellObjects/ShellItem.cs
+++ b/Windows.Shell.Common/ShellObjects/ShellItem.cs
@@ -696,7 +696,7 @@ namespace Vanara.Windows.Shell
/// One or more of the option flags.
/// The resulting image.
///
- public SafeHBITMAP GetImage(SIZE size, ShellItemGetImageOptions flags) => Images.GetImageAsync(size, flags).Result;
+ public SafeHBITMAP GetImage(SIZE size, ShellItemGetImageOptions flags) => Images.GetImage(size, flags);
/// Gets a property description list object given a reference to a property key.
///
diff --git a/Windows.Shell.Common/ShellObjects/ShellItemImages.cs b/Windows.Shell.Common/ShellObjects/ShellItemImages.cs
index d87a23de..8a12dbcf 100644
--- a/Windows.Shell.Common/ShellObjects/ShellItemImages.cs
+++ b/Windows.Shell.Common/ShellObjects/ShellItemImages.cs
@@ -27,7 +27,7 @@ namespace Vanara.Windows.Shell
/// If set to , ignore the use post vista interfaces like .
/// The resulting image.
///
- public async Task GetImageAsync(SIZE size, ShellItemGetImageOptions flags = 0, bool forcePreVista = false) => await TaskAgg.Run(() =>
+ public SafeHBITMAP GetImage(SIZE size, ShellItemGetImageOptions flags = 0, bool forcePreVista = false)
{
SafeHBITMAP hbmp = SafeHBITMAP.Null;
HRESULT hr = HRESULT.E_FAIL;
@@ -60,14 +60,14 @@ namespace Vanara.Windows.Shell
}
else
{
- throw hr.GetException();
+ throw hr.GetException()!;
}
}
// If you got a bitmap, resize based on flags
- if (sz == size.Width || (sz > size.Width && flags.IsFlagSet(ShellItemGetImageOptions.BiggerSizeOk)))
+ if (sz == size.Width || sz > size.Width && flags.IsFlagSet(ShellItemGetImageOptions.BiggerSizeOk))
return hbmp;
- if ((sz > size.Width && flags.IsFlagSet(ShellItemGetImageOptions.ResizeToFit)) || (sz < size.Width && flags.IsFlagSet(ShellItemGetImageOptions.ScaleUp)))
+ if (sz > size.Width && flags.IsFlagSet(ShellItemGetImageOptions.ResizeToFit) || sz < size.Width && flags.IsFlagSet(ShellItemGetImageOptions.ScaleUp))
{
HANDLE hbmpcp = CopyImage(hbmp.DangerousGetHandle(), LoadImageType.IMAGE_BITMAP, size.Width, size.Height, CopyImageOptions.LR_CREATEDIBSECTION);
if (hbmpcp.IsNull) Win32Error.ThrowLastError();
@@ -76,6 +76,18 @@ namespace Vanara.Windows.Shell
}
return hbmp;
- }, System.Threading.CancellationToken.None);
+ }
+
+ ///
+ /// Gets an image that represents this item. The default behavior is to load a thumbnail. If there is no thumbnail for the current
+ /// item, it retrieves the icon of the item. The thumbnail or icon is extracted if it is not currently cached.
+ ///
+ /// A structure that specifies the size of the image to be received.
+ /// One or more of the option flags.
+ /// If set to , ignore the use post vista interfaces like .
+ /// The resulting image.
+ ///
+ public async Task GetImageAsync(SIZE size, ShellItemGetImageOptions flags = 0, bool forcePreVista = false) => await TaskAgg.Run(() =>
+ GetImage(size, flags, forcePreVista), System.Threading.CancellationToken.None);
}
}
\ No newline at end of file