如何使用Windows API枚举物理驱动器上的卷? [英] How to enumerate the volumes on a phyiscal drive using Windows API?

查看:87
本文介绍了如何使用Windows API枚举物理驱动器上的卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建系统中所有(固定)磁盘的分区及其卷的列表(类似:PhyiscalDrive0,分区1,C:\; PhyiscalDrive0,分区2,D:\; ...)。我已经通过SetupApi和IOCTL_STORAGE_GET_DEVICE_NUMBER获得了已安装磁盘的列表,以及分区的数量。

I'm trying to create a list of partitions and their volumes of all the (fixed) disks in the system (Something like: PhyiscalDrive0, Partition 1, C:\; PhyiscalDrive0, Partition 2, D:\; ...) . I already got the list of installed disks via SetupApi and IOCTL_STORAGE_GET_DEVICE_NUMBER, as well as the number of partition.

我遇到的问题是如何找出驱动器号

The problem I'm having is how to find out the drive letters that are mounted to a partiticular partition (in meaning of partition 1 of Physical drive is C:\, for example)?

感谢您的帮助,

p>

Willi K。

Willi K.

推荐答案

您可能要使用的API是存储管理API 。这提供了一种查询几乎所有您想要的方法。特别是,驱动器号是 MSFT_Volume 类。该API不是C ++最友好的,这就是为什么我不提供示例查询,但是有一个此处的示例,该示例显示了如何编写查询。

The API you probably want to use is the Storage Management API. This provides a way to query just about anything you want. In particular, the drive letters are part of the MSFT_Volume class. The API isn't the friendliest for C++, which is why I'm not providing a sample query, but there's a sample here that shows how to write queries.

这篇关于如何使用Windows API枚举物理驱动器上的卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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