Skip to content

Commit 30d10bb

Browse files
committed
Add try catch for register key check
1 parent 43c74f0 commit 30d10bb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
using Microsoft.Win32;
22

33
namespace Flow.Launcher.Helper;
4+
45
internal static class WindowsMediaPlayerHelper
56
{
67
internal static bool IsWindowsMediaPlayerInstalled()
78
{
8-
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MediaPlayer");
9-
return key?.GetValue("Installation Directory") != null;
9+
try
10+
{
11+
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MediaPlayer");
12+
return key?.GetValue("Installation Directory") != null;
13+
}
14+
catch
15+
{
16+
return false;
17+
}
1018
}
1119
}

0 commit comments

Comments
 (0)