Search code examples
firemonkeydelphi-12-athens

Getting list of devices plugged in in a pc (windows platform)


I am working on a project and I need to get the list of plugged in devices in the PC, just like the Windows Device Manager does.

enter image description here

But I don't know how to communicate with Windows to retrive the list of available devices in Delphi Firemonkey framework. I am using Delphi 12.


Solution

  • Everything that Device Manager does is done through the "SetupDi" APIs. They are powerful, but very wordy. The devcon tool from Microsoft also does all of these functions, and the source code is available:

    https://github.com/microsoft/Windows-driver-samples/tree/main/setup/devcon

    Please note that this is complicated. Be patient, follow the sample.