在Windows 8.1上启用和禁用使用c#的USB设备的任何API更改?

我想切换启用USB启用设备禁用,反之亦然。 我使用NetworkAdapter api在Windows 7中切换USB,它工作正常。 但是,当我使用相同的一段代码的Windows 8.1,即使api已禁用我的USB设备,更改不反映在设备pipe理器。 我可以确认设备已经真正被禁用,一旦我popup并重新连接我的USB。 我想知道是否有任何Windows 8.1的API更改,我可能不知道。 如果不是我哪里错了?

我的一段代码是:

switch (requiredstatus) { case "Disable": SelectQuery query = new SelectQuery("Win32_NetworkAdapter","NetConnectionStatus=2"); ManagementObjectSearcher search = new ManagementObjectSearcher(query); foreach (ManagementObject device in search.Get()) { NetworkAdapter adapter = new NetworkAdapter(device); // Identify the adapter you wish to disable here. // Here, we're selecting the LAN adapters. if (adapter.Name.Contains("Device1")) { //Console.WriteLine("Disable"); adapter.Disable(); result = true; } } break; case "Enable": SelectQuery query1 = new SelectQuery("Win32_NetworkAdapter","NetConnectionStatus=0"); ManagementObjectSearcher search1 = new ManagementObjectSearcher(query1); foreach (ManagementObject device in search1.Get()) { NetworkAdapter adapter = new NetworkAdapter(device); // Identify the adapter you wish to disable here. // Here, we're selecting the LAN adapters. if (adapter.Name.Contains("Device1")) { //Console.WriteLine("Enable"); adapter.Enable(); result = true; } } break; }