private void chkClockSeconds_CheckedChanged(object sender, EventArgs e) { string key = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; if (chkClockSeconds.Checked) { RegistryManager.AddValue(key, new RegistryValue { Name = "ShowSecondsInSystemClock", Value = 1, ValueKind = RegistryValueKind.DWord }); } else { RegistryManager.DeleteValue($"{key}\\ShowSecondsInSystemClock"); } }
private void chkFloatingSearch_CheckedChanged(object sender, EventArgs e) { string parent = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search"; if (chkFloatingSearch.Checked) { RegistryManager.AddValue(parent, new RegistryValue { Name = "ImmersiveSearch", Value = 1, ValueKind = RegistryValueKind.DWord }); } else { RegistryManager.DeleteValue($"{parent}\\ImmersiveSearch"); } }
private void chkShortcutArrows_CheckedChanged(object sender, EventArgs e) { string key = @"HKEY_CLASSES_ROOT\lnkfile"; if (chkShortcutArrows.Checked) { RegistryManager.DeleteValue($"{key}\\IsShortcut"); } else { RegistryManager.AddValue(key, new RegistryValue { Name = "IsShortcut", Value = "", ValueKind = RegistryValueKind.String }); } }
private void chkHideDrives_CheckedChanged(object sender, EventArgs e) { string key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer"; if (chkHideDrives.Checked) { RegistryManager.AddValue(key, new RegistryValue() { Name = "NoDrives", Value = 67108863, ValueKind = RegistryValueKind.DWord }); } else { RegistryManager.DeleteValue($"{key}\\NoDrives"); } }
private void chkDisableLockScreen_CheckedChanged(object sender, EventArgs e) { string parent = @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows"; if (chkDisableLockScreen.Checked) { RegistryManager.CreateKey(parent, "Personalization"); RegistryManager.AddValue($"{parent}\\Personalization", new RegistryValue { Name = "NoLockScreen", Value = 1, ValueKind = RegistryValueKind.DWord }); } else { RegistryManager.DeleteKey(parent, "Personalization"); } }
private void chkRestrictChangingDesktopWallpaper_CheckedChanged(object sender, EventArgs e) { string parentKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies"; if (chkRestrictChangingDesktopWallpaper.Checked) { RegistryKey key = RegistryManager.CreateKey(parentKey, "System"); string lastWallpaper = RegistryManager.GetKeyValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "WallPaper").Value.ToString(); RegistryManager.AddValue(key.Name, new RegistryValue() { Name = "WallPaper", Value = lastWallpaper, ValueKind = RegistryValueKind.String }); } else { RegistryManager.DeleteKey(parentKey, "System"); } }
private void btnAdd_Click(object sender, EventArgs e) { string name = txtName.Text.Trim(); string type = cmbValueKind.Text.Trim(); string value = txtValue.Text.Trim(); if (RegistryManager.GetKeyValues(_key).Any(item => item.Name == name)) { MessageBox.Show("این نام استفاده شده است.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (name.Length == 0 || type.Length == 0 || value.Length == 0) { MessageBox.Show("لطفا مقادیر را وارد نمایید", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } RegistryValueKind valueKind; if (!Enum.TryParse(type, out valueKind)) { MessageBox.Show("نوع داده وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } object val = null; switch (valueKind) { case RegistryValueKind.String: case RegistryValueKind.ExpandString: { val = value; } break; case RegistryValueKind.Binary: { char[] bytesList = value.ToCharArray(); foreach (char item in bytesList) { if ((int)item > byte.MaxValue) { MessageBox.Show("مقدار وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } byte[] bytes = bytesList.Select(b => (byte)b).ToArray(); val = bytes; } break; case RegistryValueKind.DWord: { UInt32 v = 0; if (!UInt32.TryParse(value, out v)) { MessageBox.Show("مقدار وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } val = v; } break; case RegistryValueKind.MultiString: { val = value.Replace(';', '\0'); } break; case RegistryValueKind.QWord: { UInt64 v = 0; if (!UInt64.TryParse(value, out v)) { MessageBox.Show("مقدار وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } val = v; } break; } RegistryManager.AddValue(_key, new RegistryValue { Name = name, ValueKind = valueKind, Value = val }); MessageBox.Show("مقدار افزوده شد.", "افزودن مقدار", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; }