static public bool DeleteRegedit(string name) { bool _exit = false; string[] subkeyName; RegistryKey hkml = Registry.CurrentUser; RegistryKey software = hkml.OpenSubKey("SOFTWARE", true); RegistryKey YeMainKey = software.OpenSubKey("RXYFYECHAOCHENG", true); if (YeMainKey == null) { software.CreateSubKey("RXYFYECHAOCHENG"); YeMainKey = software.OpenSubKey("RXYFYECHAOCHENG", true); } subkeyName = YeMainKey.GetSubKeyNames(); foreach (string KeyName in subkeyName) { RegistryKey registryKey = YeMainKey.OpenSubKey(name, true); if (KeyName.Trim().ToUpper() == name.Trim().ToUpper() && registryKey != null) { YeMainKey.DeleteSubKey(name); _exit = true; hkml.Close(); software.Close(); registryKey.Close(); return(_exit); } } hkml.Close(); software.Close(); YeMainKey.Close(); return(_exit); }
/// <summary> /// 注册表存在检查 /// </summary> /// <param name="name">待确认的注册表名称</param> /// <returns></returns> static public bool IsRegeditExit(string name) { bool _exit = false; string[] subkeyName; RegistryKey hkml = Registry.CurrentUser; RegistryKey software = null; software = hkml.OpenSubKey("SOFTWARE", true); RegistryKey admindir = software.OpenSubKey("RXYFYECHAOCHENG", true); if (admindir == null) { software.CreateSubKey("RXYFYECHAOCHENG"); admindir = software.OpenSubKey("RXYFYECHAOCHENG", true); } subkeyName = admindir.GetSubKeyNames(); foreach (string KeyName in subkeyName) { RegistryKey registryKey = admindir.OpenSubKey(name, true); if (KeyName.Trim().ToUpper() == name.Trim().ToUpper() && registryKey != null) { _exit = true; hkml.Close(); software.Close(); admindir.Close(); return(_exit); } } hkml.Close(); software.Close(); admindir.Close(); return(_exit); }
private string[] Validate() { List <string> errors = new List <string>(); if (KeyName.Trim() == "") { errors.Add("Domain name cannot be blank."); } if (KeyName.ToLower().Trim() == "www") { errors.Add("Domain name not allowed."); } if (KeyName.ToLower().Trim() == "api") { errors.Add("Domain name not allowed."); } if (KeyName.ToLower().Trim() == "admin") { errors.Add("Domain name not allowed."); } if (KeyName.ToLower().Trim() == "master") { errors.Add("Domain name not allowed."); } if (!IsValidEmail(Email.Trim())) { errors.Add("Invalid email address."); } if (Password.Trim().Length < 6) { errors.Add("Password must be at least 6 characters."); } if (errors.Count == 0) { if (System.Text.RegularExpressions.Regex.Match(KeyName, "[A-Za-z0-9\\-_]{1,99}").Value != KeyName) { errors.Add("Domain name can only contain letters, numbers and hyphens."); } } if (errors.Count == 0) { if (StreamingLiveLib.Site.LoadByKeyName(KeyName.ToLower().Trim()) != null) { errors.Add("Sorry, this domain name is already taken."); } } if (errors.Count == 0) { if (StreamingLiveLib.User.LoadByEmail(Email) != null) { errors.Add("There is already an account registered with this email address. Log in instead."); } } return(errors.ToArray()); }