mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PTRun]Check we're not trying to get an icon with an empty filename (#29990)
This commit is contained in:
@@ -83,13 +83,17 @@ namespace Wox.Infrastructure.Image
|
|||||||
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
|
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
|
||||||
{
|
{
|
||||||
IntPtr hBitmap = IntPtr.Zero;
|
IntPtr hBitmap = IntPtr.Zero;
|
||||||
|
string targetLinkedFilePath = string.Empty;
|
||||||
if (Path.GetExtension(fileName).Equals(".lnk", StringComparison.OrdinalIgnoreCase))
|
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.
|
// 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();
|
IShellLinkHelper shellLinkHelper = new ShellLinkHelper();
|
||||||
|
targetLinkedFilePath = shellLinkHelper.RetrieveTargetPath(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
string targetFilePath = shellLinkHelper.RetrieveTargetPath(fileName);
|
if (!string.IsNullOrEmpty(targetLinkedFilePath))
|
||||||
hBitmap = ExtractIconToHBitmap(targetFilePath);
|
{
|
||||||
|
hBitmap = ExtractIconToHBitmap(targetLinkedFilePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user