从逻辑盘符获得物理驱动号

本文介绍了一种方法来获取特定逻辑驱动器(如C:)所对应的物理磁盘编号。通过使用 IOCTL_STORAGE_GET_DEVICE_NUMBER 方法可以得到这个编号,并将其附加到 //.//PhysicalDrive 后面来确定具体的物理磁盘。对于跨越多个硬盘的卷,则需要使用 IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS 方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 How to get the PhysicalDrive number which the logical drive located?
> Like how to get the PhysicalDrive number of "C:" logical drive?
> Thanks a lot!

Open your //.//C:, then issue IOCTL_STORAGE_GET_DEVICE_NUMBER, this returns
a number. Append the decimal representation of this number to
//.//PhysicalDrive, and you should be all set. This method will not work
with volumes that span multiple harddrives, but your question does not make
sense in that case, either. If you do want to handle that case, check out
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.

The QueryDosDevice() method mentioned by Eugene is no longer practicable
without using undocumented symlink manipulation API.

The only other way I know of is to use the PnP/setup API to walk the device
tree, but this is too much work for such a small function.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值