#pragma once #include #include #include // Enumerate every COM port (Ports class) whose USB Hardware ID contains // "VID_&PID_" (case-insensitive substring). Returns the // list of "COMn" strings sorted ascending by trailing integer (D-10: // lowest COM number wins). Returns an empty vector on no matches OR on // SetupAPI failure (the helper never throws). // // Thread-safety: callable from any worker thread. MUST NOT be called from // DllMain / DLL_PROCESS_DETACH (Pitfall 7 — SetupAPI uses loader lock). // // Example: ScanForUsbComPorts(0x303A, 0x1001) on a system with the // ESP32-C3 plugged in at COM11 returns {"COM11"}. std::vector ScanForUsbComPorts(uint16_t vid, uint16_t pid);