class RegisteryWriter { public static bool WriteDefaultLogin(string username, string password) { const string subKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"; RegistryKey registeryKey = Registry.LocalMachine.CreateSubKey(subKey); if (registeryKey == null) return false; else { registeryKey.SetValue("AutoAdminLogon", "1"); registeryKey.SetValue("DefaultUserName", username); registeryKey.SetValue("DefaultPassword", password); registeryKey.Close(); return true; } } public static bool RemoveDefaultLogin() { const string subKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"; RegistryKey registeryKey = Registry.LocalMachine.CreateSubKey(subKey); if (registeryKey == null) return false; else { registeryKey.DeleteValue("DefaultUserName", false); registeryKey.DeleteValue("DefaultPassword", false); registeryKey.DeleteValue("AutoAdminLogon", false); registeryKey.Close(); return true; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)