- Notifications
You must be signed in to change notification settings - Fork1
This Library List of USB devices in Windows and events for changes
License
NotificationsYou must be signed in to change notification settings
bakhshipoor/USBDevices
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This library provides functionalities to list USB devices on Windows and handle events for device changes. It is based on C++ code and utilizes Windows IOCTL,setupapi.dll
,kernel32.dll
, andfmifs.dll
.
- List all connected USB devices
- Monitor USB device connection and disconnection events
- Filter USB devices by VID, PID, and Service
- .Net Core 8.0
- Windows Desktop
- Disk Drive
- Disk Partition
- Logical Disk
- Connected
- Disconnected
To install this library, clone the repository and build the solution using Visual Studio.
git clone https://github.com/bakhshipoor/USBDevices.gitcd USBDevices
- Create a new instance of the
USBDevicesList
class:
publicUSBDevicesListUSBDevicesCollection{get;set;}USBDevicesCollection=newUSBDevicesList();
- Enable or disable connection and disconnection events as needed:
USBDevicesCollection.ConnectedEventStatus=false;USBDevicesCollection.DisconnectedEventStatus=true;
- Enable device filtering and set filters:
USBDevicesCollection.EnableFilterDevice();USBDevicesCollection.FilterDeviceStatus=true;USBDevicesCollection.SetDeviceToFilter("xxxx","yyyy","Service Name");
- Add event handlers for initial collection completion and device changes:
USBDevicesCollection.InitialCollectionsComplete+=USBDevicesCollections_InitialCollectionsComplete;USBDevicesCollection.DeviceChanged+=USBDevicesCollections_DeviceChanged;
- Start monitoring USB devices:
USBDevicesCollection.Start();
- Access the list of USB devices:
ObservableCollection<USBDevice>devices=USBDevicesCollection.USBDevices;
This library includes two example projects:
USBDevicesDemo
: A simple WPF application to view properties of connected USB devices.CopyFilesToFlash
: A WPF MVVM application that automatically copies files to a USB flash drive.
This project is licensed under the MIT License. See theLICENSE file for details.
Contributions are welcome! Please fork the repository and submit a pull request.
Thanks to all contributors and supporters.
Feel free to check the repository atUSBDevices.
About
This Library List of USB devices in Windows and events for changes
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published