Use setupapi functions. Something like this:
unsigned devIndex;
SP_DEVINFO_DATA devInfo;
ULONG ulStatus, ulProblemNumber;
CONFIGRET crRet;
HDEVINFO devs;
devs = SetupDiGetClassDevsEx(NULL,NULL,NULL,DIGCF_ALLCLASSES,NULL,NULL,NULL);
devInfo.cbSize = sizeof(devInfo);
for(devIndex=0;SetupDiEnumDeviceInfo(devs,devIndex,&devInfo);devIndex++)
{
crRet=CM_Get_DevNode_Status(&ulStatus,&ulProblemNumber,devInfo.DevInst,0);
if ( ( crRet == CR_SUCCESS ) && (ulStatus & DN_LEGACY_DRIVER ) )
{
if ( SetupDiGetDeviceRegistryProperty(devs,&devInfo,SPDRP_DEVICEDESC,NULL,(PBYTE)Buffer,sizeof Buffer,ULL) )
_tprintf(TEXT("%sn"),Buffer );
}
}
SetupDiDestroyDeviceInfoList ( devs );