Skip to content

Commit a0a86a6

Browse files
authored
Fixed a crash that would sometimes occur when selecting some options on the right click context menu (#1881)
1 parent e5d3236 commit a0a86a6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Files.Launcher/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private static Func<string, bool> FilterMenuItems(bool showOpenMenu)
334334
{
335335
var knownItems = new List<string>() {
336336
"opennew", "openas", "opencontaining", "opennewprocess",
337-
"runas", "runasuser", "pintohome",
337+
"runas", "runasuser", "pintohome", "PinToStartScreen",
338338
"cut", "copy", "delete", "properties", "link",
339339
"WSL", "Windows.ModernShare", "Windows.Share", "setdesktopwallpaper",
340340
Win32API.ExtractStringFromDLL("shell32.dll", 30312), // SendTo menu

Files.Launcher/Win32API_ContextMenu.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,10 @@ public void InvokeVerb(string verb)
147147
pici.cbSize = (uint)Marshal.SizeOf(pici);
148148
cMenu.InvokeCommand(pici);
149149
}
150-
catch (COMException ex)
150+
catch (Exception ex) when (
151+
ex is COMException
152+
|| ex is UnauthorizedAccessException)
151153
{
152-
// Usually it's "invalid window handle"
153154
Debug.WriteLine(ex);
154155
}
155156
}
@@ -165,9 +166,10 @@ public void InvokeItem(int itemID)
165166
pici.cbSize = (uint)Marshal.SizeOf(pici);
166167
cMenu.InvokeCommand(pici);
167168
}
168-
catch (COMException ex)
169+
catch (Exception ex) when (
170+
ex is COMException
171+
|| ex is UnauthorizedAccessException)
169172
{
170-
// Usually it's "invalid window handle"
171173
Debug.WriteLine(ex);
172174
}
173175
}

0 commit comments

Comments
 (0)