Skip to content

Commit e6b8a0d

Browse files
Catch exception in ShellLinkHelper
1 parent 207b29f commit e6b8a0d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Runtime.InteropServices;
44
using Accessibility;
55
using System.Runtime.InteropServices.ComTypes;
6+
using Flow.Launcher.Plugin.Program.Logger;
67

78
namespace Flow.Launcher.Plugin.Program.Programs
89
{
@@ -119,9 +120,19 @@ public string retrieveTargetPath(string path)
119120
// To set the app description
120121
if (!String.IsNullOrEmpty(target))
121122
{
122-
buffer = new StringBuilder(MAX_PATH);
123-
((IShellLinkW)link).GetDescription(buffer, MAX_PATH);
124-
description = buffer.ToString();
123+
try
124+
{
125+
buffer = new StringBuilder(MAX_PATH);
126+
((IShellLinkW)link).GetDescription(buffer, MAX_PATH);
127+
description = buffer.ToString();
128+
}
129+
catch (COMException e)
130+
{
131+
// C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\MiracastView.lnk always cause exception
132+
ProgramLogger.LogException($"|IShellLinkW|retrieveTargetPath|{path}" +
133+
"|Error caused likely due to trying to get the description of the program",
134+
e);
135+
}
125136

126137
buffer.Clear();
127138
((IShellLinkW)link).GetArguments(buffer, MAX_PATH);

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,6 @@ private static Win32 LnkProgram(string path)
309309

310310
return program;
311311
}
312-
catch (COMException e)
313-
{
314-
// C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\MiracastView.lnk always cause exception
315-
ProgramLogger.LogException($"|Win32|LnkProgram|{path}" +
316-
"|Error caused likely due to trying to get the description of the program",
317-
e);
318-
319-
return Default;
320-
}
321312
catch (FileNotFoundException e)
322313
{
323314
ProgramLogger.LogException($"|Win32|LnkProgram|{path}" +

0 commit comments

Comments
 (0)