Skip to content

Commit 08c8b8c

Browse files
committed
Do not show UI when shortcuts cannot be resolved
1 parent bf98a73 commit 08c8b8c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/ShellLinkHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
namespace Flow.Launcher.Plugin.Program.Programs
1010
{
11-
class ShellLinkHelper
11+
public class ShellLinkHelper
1212
{
13-
1413
// Reference : http://www.pinvoke.net/default.aspx/Interfaces.IShellLinkW
1514
[ComImport(), Guid("00021401-0000-0000-C000-000000000046")]
1615
public class ShellLink
@@ -28,7 +27,9 @@ public unsafe string retrieveTargetPath(string path)
2827
const int STGM_READ = 0;
2928
((IPersistFile)link).Load(path, STGM_READ);
3029
var hwnd = new HWND(IntPtr.Zero);
31-
((IShellLinkW)link).Resolve(hwnd, 0);
30+
// Use SLR_NO_UI to avoid showing any UI during resolution, like Problem with Shortcut dialogs
31+
// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-resolve
32+
((IShellLinkW)link).Resolve(hwnd, (uint)SLR_FLAGS.SLR_NO_UI);
3233

3334
const int MAX_PATH = 260;
3435
Span<char> buffer = stackalloc char[MAX_PATH];
@@ -79,6 +80,6 @@ public unsafe string retrieveTargetPath(string path)
7980
Marshal.ReleaseComObject(link);
8081

8182
return target;
82-
}
83+
}
8384
}
8485
}

0 commit comments

Comments
 (0)