NServiceBus.LicenseLocationConventions.GetHKLMLicense C# (CSharp) Method

GetHKLMLicense() static private method

static private GetHKLMLicense ( string softwareKey = "NServiceBus", string subKey = null ) : string
softwareKey string
subKey string
return string
        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;
        }