using Microsoft.Win32;
using System.Security;
namespace Nikse.SubtitleEdit.Core
{
public static class RegistryUtil
{
///
/// Retrieves the specified registry subkey value.
///
/// The path of the subkey to open.
/// The name of the value to retrieve.
/// The value of the subkey requested, or null if the operation failed.
public static string GetValue(string keyName, string valueName)
{
RegistryKey key = null;
try
{
key = Registry.LocalMachine.OpenSubKey(keyName);
if (key != null)
{
var value = key.GetValue(valueName);
if (value != null)
{
return (string)value;
}
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read the registry key.
}
finally
{
if (key != null)
{
key.Dispose();
}
}
return null;
}
}
}