Sometimes Developers Want to list or Identify USB devices connected to the machine and perform some actions to the USB devices programmatically. How do enumerate the USB devices quickly? Don’t know how to do it?. Don’t worry. MiTec’s System Information Management Suite’s component helps to enumerate the connected USB devices; we will learn how to use the TMiTec_USB component in this blog post.
Platforms: Windows.
Installation Steps:
You can easily install this Component Suite from GetIt Package Manager. The steps are as follows.
- Navigate In RAD Studio IDE->Tools->GetIt Package Manager->select Components in Categories->Components->Trail -MiTec system Information Component Suite 14.3 and click Install Button.
- Read the license and Click Agree All. An Information dialog saying ‘Requires a restart of RAD studio at the end of the process. Do you want to proceed? click yes and continue.
- It will download the plugin and installs it. Once installed Click Restart now.
How to run the Demo app:
- Navigate to the System Information Management Suite trails setup, Demos folder which is installed during Get It installation e.g) C:UsersDocumentsEmbarcaderoStudio21.0CatalogRepositoryMiTeC-14.3DemosDelphi4
- Open the USBEnum project in RAD studio 10.4.1 compile and Run the application.
- This Demo App shows how to list down the connected USB devices, enumerate among them and access its properties.
Components used in MSIC USBEnum Demo App:
- TMiTeC_USB: Enumerates all connected USB devices and their properties.
- TMiTec_DeviceMonitor : Catches USB, Bluetooth devices or TV/monitor connection/disconnection, volumes mount/unmount, CD/DVD insert/eject and other events from other devices
- TTreeView to list the USB devices nodes and TListView to show the connected USB Device Node properties.
- TButton’s to save, refresh and eject selected USB device.
Implementation Details:
- An instance is created USB of TMiTeC_USB. Call USB.RefreshData, Add list of USB nodes to the tree node by loop through USB.USBNodeCount. Ensure the USB Devices is connected before adding its property value to the list view.
- Display the selected USB Device Node properties as shown below.
- On clicking Remove Button, Check whether the selected USB Device Node is eject able using Method IsEjectable and Eject the Device.
- Use DeviceMonitor events OnDevicConnect, OnDeviceDisconnect, OnVolumeConnect, OnVolumeDisconnect to identify the device arrival/removal and refresh the tree view accordingly.
It’s that simple to enumerate USB Devices connected and list its properties for your application. Use this MiTeC component suite and get the job done quickly.
With the use of Windows IDE, you can quickly enumerate USB devices on Windows when developing in Delphi or C++ environments. Try your Free Trial here.