Once upon a time, I wrote a utility for a client to do just that, but for GPS, not for a modem.
I just looked at it, and bits that might be useful are:
GUID guid = GUID_DEVCLASS_PORTS; SP_DEVICE_INTERFACE_DATA interfaceData; ZeroMemory(&interfaceData, sizeof(interfaceData)); interfaceData.cbSize = sizeof(interfaceData); SP_DEVINFO_DATA devInfoData; ZeroMemory(&devInfoData, sizeof(devInfoData)); devInfoData.cbSize = sizeof(devInfoData); if(SetupDiEnumDeviceInfo( hDeviceInfo,
(You call this bit in a loop in nDevice increments)
and then
BYTE friendlyName[300]; if(SetupDiGetDeviceRegistryProperty(hDeviceInfo, &devInfoData, SPDRP_FRIENDLYNAME, NULL, friendlyName, sizeof(friendlyName), NULL)) { strFriendlyNames += (LPCTSTR)friendlyName; strFriendlyNames += '\n'; }
which finds the name of the device.
Hope this helps you in the right direction.
Will dean
source share