禁止更改颜色选项

Posted on 2019-01-29 04:27  努力成长静待花开  阅读(179)  评论(0编辑  收藏  举报

实现效果:

  

 知识运用:

  Policies\System子键的NoDispAppearancePage键值

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            RegistryKey rk = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\System");
            rk.SetValue("NoDispAppearancePage",1,RegistryValueKind.DWord);
            MessageBox.Show("设置成功!");
        }
        private void button2_Click(object sender, EventArgs e)
        {
            RegistryKey rk = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\System");
            rk.SetValue("NoDispAppearancePage", 0, RegistryValueKind.DWord);
            MessageBox.Show("设置成功!");
        }