实现效果:
知识运用:
RegistryKey类的CreateSubKey和SetValue方法
实现代码:
private void button1_Click(object sender, EventArgs e) { RegistryKey regMain; RegistryKey regChild; regMain = Registry.CurrentUser; regChild = regMain.CreateSubKey(@"Software\Policies\Microsoft\Windows\System"); regChild.SetValue("DisableCMD",1); regChild.Close(); MessageBox.Show("禁止成功!"); } private void button2_Click(object sender, EventArgs e) { RegistryKey regMain; RegistryKey regChild; regMain = Registry.CurrentUser; regChild = regMain.CreateSubKey(@"Software\Policies\Microsoft\Windows\System"); regChild.SetValue("DisableCMD", 0); regChild.Close(); MessageBox.Show("禁止成功!"); }