0

I am trying to detect different types of USB cables inserted. It is possible to capture the event of the device inserted. However, if the device is new, it first installs the device driver, and it will not detect the cable unless the cable is unplugged and re-inserted. Is there a way in .net where we can detect the inserted device even if the device is new or after the new driver is installed?

jinto johnson
  • 21
  • 1
  • 7

1 Answers1

1

You don't detect cables, you detect devices.

This is the Win32 documentation area for devices: https://learn.microsoft.com/en-us/windows/win32/devio/device-management

In Win32 land, you call RegisterDeviceNotification and you will then be informed when devices are added or removed https://learn.microsoft.com/en-us/windows/win32/devio/registering-for-device-notification

Here is a link on how to do this in C# Using RegisterDeviceNotification in a .NET app

Neil
  • 11,059
  • 3
  • 31
  • 56