禁止和允许显示任务栏的右键菜单

实现效果:

  禁止和允许显示任务栏的右键菜单

知识运用:

   notraycontextmenu键

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                RegistryKey regkey;
                regkey = Registry.CurrentUser;
                regkey = regkey.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
                regkey.SetValue("notraycontextmenu", 1, RegistryValueKind.DWord);
                regkey.Close();
                if (MessageBox.Show("设置完成!") == DialogResult.OK)
                {
                    RefreshSystem();
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                RegistryKey regkey;
                regkey = Registry.CurrentUser;
                regkey = regkey.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
                regkey.SetValue("notraycontextmenu", 0, RegistryValueKind.DWord);
                regkey.Close();
                if (MessageBox.Show("设置完成!") == DialogResult.OK)
                {
                    RefreshSystem();
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }

  

上一篇:设置IE浏览器的默认下载路径


下一篇:QMessageBox消息框