[PTRun]Check we're not trying to get an icon with an empty filename (#29990)

This commit is contained in:
Jaime Bernardo
2023-11-23 14:14:48 +00:00
committed by GitHub
parent 63226e656a
commit 9c1fb53d2a

View File

@@ -83,13 +83,17 @@ namespace Wox.Infrastructure.Image
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{
IntPtr hBitmap = IntPtr.Zero;
string targetLinkedFilePath = string.Empty;
if (Path.GetExtension(fileName).Equals(".lnk", StringComparison.OrdinalIgnoreCase))
{
// If the file has a '.lnk' extension, it is a shortcut file. Use the shellLinkHelper to retrieve the actual target file path from the shortcut.
IShellLinkHelper shellLinkHelper = new ShellLinkHelper();
targetLinkedFilePath = shellLinkHelper.RetrieveTargetPath(fileName);
}
string targetFilePath = shellLinkHelper.RetrieveTargetPath(fileName);
hBitmap = ExtractIconToHBitmap(targetFilePath);
if (!string.IsNullOrEmpty(targetLinkedFilePath))
{
hBitmap = ExtractIconToHBitmap(targetLinkedFilePath);
}
else
{