public static bool GetSettingsExist(string instanceName)
        {
            bool result;

            using (RegistryKey registryKey = AdamServiceSettings.GetAdamServiceSubKey(instanceName).Open())
            {
                result = (null != registryKey);
            }
            return(result);
        }
        public static void DeleteFromRegistry(string instanceName)
        {
            RegistrySubKey adamServiceSubKey = AdamServiceSettings.GetAdamServiceSubKey(instanceName);

            adamServiceSubKey.DeleteTreeIfExist();
            using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\EdgeTransportRole\\AdamSettings"))
            {
                if (registryKey != null && registryKey.SubKeyCount == 0)
                {
                    Registry.LocalMachine.DeleteSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\EdgeTransportRole\\AdamSettings");
                }
            }
        }
        public void SaveToRegistry()
        {
            RegistrySubKey adamServiceSubKey = AdamServiceSettings.GetAdamServiceSubKey(this.InstanceName);

            adamServiceSubKey.DeleteTreeIfExist();
            using (RegistryKey registryKey = adamServiceSubKey.Create())
            {
                registryKey.SetValue("DataFilesPath", this.DataFilesPath);
                registryKey.SetValue("LogFilesPath", this.LogFilesPath);
                registryKey.SetValue("LdapPort", this.LdapPort);
                registryKey.SetValue("SslPort", this.SslPort);
            }
        }
        public static AdamServiceSettings GetFromRegistry(string instanceName)
        {
            AdamServiceSettings result;

            using (RegistryKey registryKey = AdamServiceSettings.GetAdamServiceSubKey(instanceName).Open())
            {
                string text  = registryKey.GetValue("DataFilesPath") as string;
                string text2 = registryKey.GetValue("LogFilesPath") as string;
                int    num   = (int)registryKey.GetValue("LdapPort");
                int    num2  = (int)registryKey.GetValue("SslPort");
                result = new AdamServiceSettings(instanceName, text, text2, num, num2);
            }
            return(result);
        }