I get a list of devices from the system using the SetupDiGetClassDevs - MSDN function.
I can also get seller ID and product ID from devices.
But I can not get the drive letter and mount path
For example, if I plug in a USB drive, I need to get a drive letter like "G: /"
Please help me get the drive letter and mount path for devices.
if (SetupDiEnumDeviceInterfaces(hDevInfo,
NULL,&GUID_DEVINTERFACE_USB_DEVICE,i,&Interface_Info))
{
wprintf(L"\tDeviccvcvcveInstanceId : %d\n", i);
pspdidd->cbSize = sizeof(*pspdidd);
SP_DEVICE_INTERFACE_DETAIL_DATA *pDetData = NULL;
DWORD dwDetDataSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA) + 256;
pDetData = (SP_DEVICE_INTERFACE_DETAIL_DATA*) malloc (dwDetDataSize);
pDetData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
SetupDiGetDeviceInterfaceDetail(hDevInfo,&Interface_Info,pDetData,dwDetDataSize,
NULL,&DeviceInfoData);
qDebug ()<<QString::fromWCharArray( pDetData->DevicePath );
}
source
share