Convert drive letter to partition id / drive id

Given the drive letter, how do I get the OSImage InstallTo Partition ID and Drive ID without using the registry?

+3
windows winapi deviceiocontrol
Feb 15 2018-12-15T00:
source share
2 answers

The Win32_DiskPartition WMI Win32_DiskPartition is what I need. Now, to figure out how to use WMI to get this information from the drive letter.

Win32_LogicalDisk also useful. An example of MSDN and https://stackoverflow.com/a/167379/

Update: Hmm, that doesn't work! In any case, not in the Windows installer ( WMI is not in Windows PE ), so I use a different QueryDosDevice answer (for example, \\.\PhysicalDisk1\Partition0 ) and hack it together. This sucks Microsoft, take the damn way in your installer.




Answer: IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS works to get Disk ID . And DeviceIoControl IOCTL_DISK_GET_PARTITION_INFO_EX (thanks TLama) gets me a Partition ID .

+5
Feb 16 '12 at 13:25
source share

Have you tried just calling QueryDosDevice ?

+2
Feb 15 2018-12-15T00:
source share



All Articles