Show USB devices connected

Hello everyone, this is my first post in this forum. I've tried searching but found nothing that solves my doubts.

I want to make a program that displays all usb devices connected to my laptop, showing their names, and the COM port they're connected to. Is that possible?

Thanks for your help!
Last edited on
A quick google search for "C++ enumerate USB devices" threw up a lot of useful-looking results, so that seems like a good starting point.
I managed to show the COM ports in use, but I'd like to get the name of the connected devices if possible. I used this code:

#using <System.dll>

using namespace System;
using namespace System::IO::Ports;
using namespace System::ComponentModel;

void main()
{
array<String^>^ serialPorts = nullptr;
try
{
// Get a list of serial port names.
serialPorts = SerialPort::GetPortNames();
}
catch (Win32Exception^ ex)
{
Console::WriteLine(ex->Message);
}

Console::WriteLine("The following serial ports were found:");

// Display each port name to the console.
for each(String^ port in serialPorts)
{
Console::WriteLine(port);
}
}
That's C# code, I don't know if I can use that in my C++ project
The main thing are the classes from the .NET framework you need to use.
It doesn't matter if you use C++ CLI or C# or VB.NET
Topic archived. No new replies allowed.