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);
            }
        }