Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

This Library List of USB devices in Windows and events for changes

License

NotificationsYou must be signed in to change notification settings

bakhshipoor/USBDevices

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.

Features

  • List all connected USB devices
  • Monitor USB device connection and disconnection events
  • Filter USB devices by VID, PID, and Service

Requirements

  • .Net Core 8.0
  • Windows Desktop

Supported Interfaces

  • Disk Drive
  • Disk Partition
  • Logical Disk

Event Types

  • Connected
  • Disconnected

Installation

To install this library, clone the repository and build the solution using Visual Studio.

git clone https://github.com/bakhshipoor/USBDevices.gitcd USBDevices

Usage

  1. Create a new instance of theUSBDevicesList class:
publicUSBDevicesListUSBDevicesCollection{get;set;}USBDevicesCollection=newUSBDevicesList();
  1. Enable or disable connection and disconnection events as needed:
USBDevicesCollection.ConnectedEventStatus=false;USBDevicesCollection.DisconnectedEventStatus=true;
  1. Enable device filtering and set filters:
USBDevicesCollection.EnableFilterDevice();USBDevicesCollection.FilterDeviceStatus=true;USBDevicesCollection.SetDeviceToFilter("xxxx","yyyy","Service Name");
  1. Add event handlers for initial collection completion and device changes:
USBDevicesCollection.InitialCollectionsComplete+=USBDevicesCollections_InitialCollectionsComplete;USBDevicesCollection.DeviceChanged+=USBDevicesCollections_DeviceChanged;
  1. Start monitoring USB devices:
USBDevicesCollection.Start();
  1. Access the list of USB devices:
ObservableCollection<USBDevice>devices=USBDevicesCollection.USBDevices;

Examples

This library includes two example projects:

  1. USBDevicesDemo: A simple WPF application to view properties of connected USB devices.
  2. CopyFilesToFlash: A WPF MVVM application that automatically copies files to a USB flash drive.

Screenshots

USBDevicesDemo-1USBDevicesDemo-2USBDevicesDemo-3USBDevicesDemo-4CopyFilesToFlash-1CopyFilesToFlash-2

License

This project is licensed under the MIT License. See theLICENSE file for details.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

Acknowledgements

Thanks to all contributors and supporters.


Feel free to check the repository atUSBDevices.


[8]ページ先頭

©2009-2025 Movatter.jp