Given a drive letter, how do I get the OSImage InstallTo Partition ID and Disk ID without using the registry?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
WMIclassWin32_DiskPartitionis what I need. Now to figure out how to useWMIto get this information from a drive letter.Win32_LogicalDiskis 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_EXTENTSworks to get theDisk ID. And DeviceIoControlIOCTL_DISK_GET_PARTITION_INFO_EX(thanks TLama) gets me thePartition ID.