Using cfgmgr32 to get device ids/instances that support a given interface class

424 views Asked by At

I'm trying to port code from SetupAPI to cfgmgr32, since Microsoft now recommends this, and I do the following query:

SetupDiGetClassDevsExA(&GUID_DEVINTERFACE_COMPORT, nullptr, nullptr, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE, nullptr, nullptr, nullptr)

to find all devices that support the COMPORT interface class. I'm trying to implement something similar using the cfgmgr32 API.

CM_Get_Device_ID_ListA does not seem to have a way to specify a filter based on supported interfaces.

CM_Get_Device_Interface_ListA gives me a list of interfaces instead of instances or device ids. I could get an instance id from the interface using CM_Get_Device_Interface_Property except that for some reason there's only a CM_Get_Device_Interface_PropertyW version and no CM_Get_Device_Interface_PropertyA version, and that would require translating everything to use wide characters, which would incur a bunch of conversions, because this needs to interface with code that only uses narrow characters (ASCII/utf-8).

Is there a better way to accomplish something equivalent?

0

There are 0 answers