diff --git a/src/CurvaLauncher/Apis/ImageUtils.FileIconHelper.cs b/src/CurvaLauncher/Apis/ImageApi.FileIconHelper.cs similarity index 93% rename from src/CurvaLauncher/Apis/ImageUtils.FileIconHelper.cs rename to src/CurvaLauncher/Apis/ImageApi.FileIconHelper.cs index 1b15047..6e5904c 100644 --- a/src/CurvaLauncher/Apis/ImageUtils.FileIconHelper.cs +++ b/src/CurvaLauncher/Apis/ImageApi.FileIconHelper.cs @@ -4,6 +4,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System; +using System.IO; namespace CurvaLauncher.Apis { @@ -87,6 +88,15 @@ enum SHGFI : uint public static ImageSource? GetEmbededIconImage(string path, int iconSize, int? iconIndex) { + if (path.Contains('%')) + { + path = Environment.ExpandEnvironmentVariables(path); + } + + if (!File.Exists(path)) + { + return null; + } // https://github.com/CoenraadS/Windows-Control-Panel-Items/ // https://gist.github.com/jnm2/79ed8330ceb30dea44793e3aa6c03f5b @@ -161,6 +171,16 @@ enum SHGFI : uint public static ImageSource? GetAssociatedIconImage(string path, bool large) { + if (path.Contains('%')) + { + path = Environment.ExpandEnvironmentVariables(path); + } + + if (!File.Exists(path)) + { + return null; + } + SHFILEINFO shFileInfo = new(); SHGFI flags = SHGFI.Icon; diff --git a/src/CurvaLauncher/Apis/ImageUtils.cs b/src/CurvaLauncher/Apis/ImageApi.cs similarity index 92% rename from src/CurvaLauncher/Apis/ImageUtils.cs rename to src/CurvaLauncher/Apis/ImageApi.cs index e4788ec..9942eb5 100644 --- a/src/CurvaLauncher/Apis/ImageUtils.cs +++ b/src/CurvaLauncher/Apis/ImageApi.cs @@ -22,9 +22,6 @@ private ImageApi() { } public ImageSource? GetEmbededIconImage(string filename, int iconSize, int? iconIndex) { - if (!File.Exists(filename)) - return null; - try { return FileIconHelper.GetEmbededIconImage(filename, iconSize, iconIndex); @@ -37,9 +34,6 @@ private ImageApi() { } public ImageSource? GetAssociatedIconImage(string filename, int iconSize) { - if (!File.Exists(filename)) - return null; - try { return FileIconHelper.GetAssociatedIconImage(filename, iconSize > 32); @@ -52,9 +46,6 @@ private ImageApi() { } public ImageSource? GetFileIcon(string filename, int iconSize) { - if (!File.Exists(filename)) - return null; - try { return diff --git a/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunApplicationPlugin.cs b/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunApplicationPlugin.cs index 120cf79..50a0a36 100644 --- a/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunApplicationPlugin.cs +++ b/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunApplicationPlugin.cs @@ -99,7 +99,7 @@ public override Task InitializeAsync() var ext = Path.GetExtension(target.FileName); if (!string.Equals(ext, ".exe", StringComparison.OrdinalIgnoreCase)) return null; - if (!File.Exists(target.FileName)) + if (!File.Exists(Environment.ExpandEnvironmentVariables(target.FileName))) return null; var name = Path.GetFileNameWithoutExtension(shortcut);