static string GetHKLMLicense(string softwareKey = "NServiceBus", string subKey = null)
{
var keyPath = @"SOFTWARE\" + softwareKey;
if (subKey != null)
{
keyPath += @"\" + subKey;
}
try
{
using (var registryKey = Registry.LocalMachine.OpenSubKey(keyPath))
{
if (registryKey != null)
{
return (string) registryKey.GetValue("License", null);
}
}
}
// ReSharper disable once EmptyGeneralCatchClause
catch (Exception)
{
//Swallow exception if we can't read HKLM
}
return null;
}