This Library List And Event USB Devices and Filter them
-
This library based on C++ codes. Using Windows IOCTL and C++ header files.
-
Using
setupapi.dll
,kernel32.dll
andfmifs.dll
files. -
.Net Core 8.0
-
Windows Desktop
-
List of USB Devices in pc
-
Supported interfaces:
- Disk Drive
- Disk Partition
- Logical Disk
-
Event Types:
- Connected
- Disconnected
-
Create new instance of class
USBDevicesList
public USBDevicesList USBDevicesCollection { get; set; }
USBDevicesCollection = new();
-
By default Connected and Disconnected events are enabled if you want you can disable each of them by:
USBDevicesCollection.ConnectedEventStatus = false;; USBDevicesCollection.DisconnectedEventStatus = true;
-
You can set filter to monitor usb devices. In this case you should enable the filter status by:
USBDevicesCollection.EnableFilterDevice();
you can diable filter status by:
USBDevicesCollection.FilterDeviceStatus = true;
after enabling, set VID, PID or Service to filter. You can fillter by any of VID, PID, Service. Such as
SetDeviceToFilter("xxxx", "yyyy", "Service Name")
. The VID value cant be null any other nullable.Service Name
such as aUSBSTOR
.USBDevicesCollection.SetDeviceToFilter("xxxx", "yyyy", "Service Name");
-
Add Events :
USBDevicesCollection.InitialCollectionsComplete += USBDevicesCollections_InitialCollectionsComplete; USBDevicesCollection.DeviceChanged += USBDevicesCollections_DeviceChanged;
-
After initial
USBDevices
class you should start the monitiring byStart()
:USBDevicesCollection.Start();
-
USBDevicesList
have propertyObservableCollection<USBDevice> USBDevices
you can access list of usb device can enumrate this observable collection.
USBDevicesDemo
a very simpleWPF
example to view properties of devices.CopyFilesToFlash
a simpleWPF
MVVM
example to work with storage interface. This example copy batch of files to usb flash disk automatically. This examples not prepared to publish just for undrestanding how to work.