Null check when reading regkey

This commit is contained in:
VictoriousRaptor 2024-10-16 11:09:17 +08:00 committed by GitHub
parent c9db565b2b
commit 2c66f01cbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,6 @@ internal static class WindowsMediaPlayerHelper
internal static bool IsWindowsMediaPlayerInstalled()
{
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MediaPlayer");
return key.GetValue("Installation Directory") != null;
return key?.GetValue("Installation Directory") != null;
}
}