请问怎么样用C#禁用和激活usb,就象超级兔子的功能一样;还有,怎样调用“控制面板”之类的程序啊;

来源:百度知道 编辑:UC知道 时间:2024/06/21 20:13:58

利用c#操作注册表可以实现
首先引用Microsoft.Win32;
部分核心代码如下:
..
using Microsoft.Win32;
...
{
//禁用usb
RegistryKey keyLocalMachine = Registry.LocalMachine;
RegistryKey key = keyLocalMachine.OpenSubKey(@"SYSTEM\CurrentCntrolSet\Services\USBSTOR", true);
key.SetValue("Start", 4);
...
//启用usb
RegistryKey keyLocalMachine = Registry.LocalMachine;
RegistryKey key = keyLocalMachine.OpenSubKey(@"SYSTEM\CurrentCntrolSet\Services\USBSTOR", true);
key.SetValue("Start", 3);
...
}

这个还真不知道,好象要调用API吧