Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //using System.Management
- public bool IsUsbDeviceConnected(string pid, string vid)
- {
- using (var searcher =
- new ManagementObjectSearcher(@"Select * From Win32_USBControllerDevice"))
- {
- using (var collection = searcher.Get())
- {
- foreach (var device in collection)
- {
- var usbDevice = Convert.ToString(device);
- if (usbDevice.Contains(pid) && usbDevice.Contains(vid))
- return true;
- }
- }
- }
- return false;
- }
Add Comment
Please, Sign In to add comment