Converting a drive letter to a Partition ID / Disk ID

 ̄綄美尐妖づ 提交于 2019-12-05 19:35:16
unixman83

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

Win32_LogicalDisk is also useful, MSDN Example, and this stackoverflow answer.

Update: Hmm, this doesn't work! Not in the Windows Installer anyway (WMI is missing from Windows PE!!) so I am using the other answer QueryDosDevice (e.g. \\.\PhysicalDisk1\Partition0) and hacking it together. This sucks Microsoft, accept a damn path in your installer.


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

Have you tried simply calling QueryDosDevice?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!