Search code examples
windowswinapiusbdevice-driver

How to find the latest com port created in my pc?


How to find the latest virtual COM port created in my Pc??

device manager -> ports -> devicename ( COM X ).

How to find that "COM x" programatically?


Solution

  • Look at the SetupApi, specifically the SetupDiEnumDeviceInfo() and CM_Get_Device_ID() functions.

    This project has some sample code that shows the usage.