How to get drive letter and mount path - MSDN

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 );

}
+3
source share
3 answers

. - API, : " X = Y". , ; - .

. - . - .

(, ). .

(, ). , , .

, ( 100 EFI, Windows 7).

- GUID (FindFirstVolume/FindNextVolume), IOCTL (IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS). /, . GetVolumePathNamesForVolumeName, ( , ​​ ).

, .

+1

, . , - CodeProject. , , , . (IOCTL_STORAGE_GET_DEVICE_NUMBER), . CodeProject ( ), .

0

Source: https://habr.com/ru/post/1748655/


All Articles