如何获得带有物理地址的驱动器号? [英] How to get the drive letter with physical address ?

查看:53
本文介绍了如何获得带有物理地址的驱动器号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取物理地址为"\\\\.\\ PHYSICALDRIVE0"的驱动器号?
如果我们提供物理地址,它应该返回分配给该驱动器的驱动器号?帮助我

How to get the drive letter with physical address like "\\\\.\\PHYSICALDRIVE0"?
If we give the physical address.. It should return the drive letter assigned to that drive?? help me

推荐答案

这是不可能的,因为物理驱动器可以包含多个驱动器号.
但是,您可以执行相反的操作,即打开一个卷并获取其所属的物理驱动器.

这是您可以做的.

1.枚举所有卷-GetLogicalDrives.
2.打开每个卷-例如. CreateFile(L"\\\\.\\C:", ...
3.用IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTSCreateFile返回的句柄上调用DeviceIoControl.
That is not possible because a physical drive can contain multiple drive letters.
You can however do the reverse, i.e, open a volume and get the physical drive to which it belongs.

Here is what you can do.

1. Enumerate all volumes - GetLogicalDrives.
2. Open each volume - eg. CreateFile(L"\\\\.\\C:", ...
3. Call DeviceIoControl on the handle returned by CreateFile with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.


这篇关于如何获得带有物理地址的驱动器号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆