using System;
using Microsoft.Win32;
using System.Text;
using System.Windows.Forms;
/****************************************
* USB应用
* Hewill
* 2008/10/08
* **************************************/
namespace USB应用
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RegistryKey regKey = Registry.LocalMachine; //读取注册列表HKEY_LOCAL_MACHINE
string keyPath = @"SYSTEM/CurrentControlSet/Services/USBSTOR"; //USB 大容量存储驱动程序
RegistryKey openKey = regKey.OpenSubKey(keyPath, true);
openKey.SetValue("Start", 3); //设置键值对(3)为开启USB(4)为关闭
openKey.Close(); //关闭注册列表读写流
MessageBox.Show("USB以启用!");
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
RegistryKey regKey = Registry.LocalMachine;
string keyPath = @"SYSTEM/CurrentControlSet/Services/USBSTOR";
RegistryKey openKey = regKey.OpenSubKey(keyPath, true);
openKey.SetValue("Start", 4);
openKey.Close();
MessageBox.Show("USB以禁用!");
this.Close();
}
}
}
usb禁用、启用
最新推荐文章于 2021-07-30 10:31:14 发布