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禁用、启用
最新推荐文章于 2019-05-08 11:38:22 发布
本文介绍了一个使用C#实现的简单应用程序,该程序能够通过修改注册表设置来启用或禁用计算机上的USB接口。通过两个按钮操作,用户可以方便地控制USB设备的接入状态。
664

被折叠的 条评论
为什么被折叠?



