Given a drive letter, how do I get the OSImage InstallTo Partition ID and Disk ID without using the registry?
Converting a drive letter to a Partition ID / Disk ID
Asked Answered
Hi; with that Partition ID you mean 1 based index of the partition ? –
Alainealair
See here technet.microsoft.com/en-us/library/ff716430.aspx. This is what I need to determine. –
Shaker
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
?
This doesn't look like it gives me the Disk ID # nor the partition ID. I am working with the program that installs Windows itself. The setup wants a disk id and a partition id. Not a virtual mapping. –
Shaker
@unixman83: So the returned "target path" isn't something along the lines of
"\\.\PhysicalDisk1\Partition0"
? –
Eyra Hmm, the docs said differently:
\Device\HarddiskVolume1
. I didn't try it. I guess that would work. I'll have to try it tomorrow. –
Shaker @unixman83: I didn't try it either. Now I see the sentence in the documentation you're talking about. I think both forms are valid, one must be a link to the other. Then we just need to figure out how to follow symbolic links in the device namespace. –
Eyra
© 2022 - 2024 — McMap. All rights reserved.