Guest User

Untitled

a guest
Dec 10th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //using System.Management
  2. public bool IsUsbDeviceConnected(string pid, string vid)
  3. {
  4. using (var searcher =
  5. new ManagementObjectSearcher(@"Select * From Win32_USBControllerDevice"))
  6. {
  7. using (var collection = searcher.Get())
  8. {
  9. foreach (var device in collection)
  10. {
  11. var usbDevice = Convert.ToString(device);
  12.  
  13. if (usbDevice.Contains(pid) && usbDevice.Contains(vid))
  14. return true;
  15. }
  16. }
  17. }
  18. return false;
  19. }
Add Comment
Please, Sign In to add comment