求软件禁用usb口示例? - C++ Builder / Windows SDK/API
禁用所有USB口,但USB键盘鼠标可用?
[解决办法]
http://topic.csdn.net/u/20111009/14/613f4f64-702a-4e1e-95c8-1b6ebd4f40cb.html
看这个行不
[解决办法]
自己项目中用到的东西,整理过了,你自己凑合着看,不知是否能帮到你。
using Microsoft.Win32;string Dir = "SYSTEM\\CurrentControlSet\\Services\\USBSTOR";//修改Key值RegistryKey hklm = Registry.CurrentUser;//注意下这句,你可以根据你的情况来选择注册表的根植RegistryKey aimdir = hklm.OpenSubKey(Dir, true);aimdir.SetValue("Start", 4);//另外如果有兴趣的话,可以看看查找键值的代码//打开注册表获取Start值。HKEY hKey;long Result;string Dir = "SYSTEM\\CurrentControlSet\\Services\\USBSTOR";Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, Dir.c_str(), 0, KEY_READ, &hKey);if (Result != ERROR_SUCCESS){ return false;}unsigned long index = 0;char NameBuf[50] = {0};unsigned long NameLen = 1024;unsigned char ValueBuf[10] = {0};unsigned long ValueLen = 1024;unsigned long Type = REG_DWORD;//其实我们通过注册表读取COM值时只需把Type值改为REG_SZ即可。unsigned int Start_keywords = 0;while(1){ memset(NameBuf, 0x00, 50); memset(ValueBuf, 0x00, 10); NameLen = 1024; ValueLen = 1024; Result = RegEnumValue(hKey, index++, NameBuf, &NameLen, NULL, &Type, ValueBuf, &ValueLen);//如果是读COM信息的话,就得对Result值进行判断:if (Result != ERROR_SUCCESS && Result != ERROR_MORE_DATA){break;} if( strcmp(NameBuf,"Start") != 0 ){continue;} Start_keywords = (unsigned int)ValueBuf; //获取Key值}