问题描述
我在谈论物理磁盘驱动器,而不是卷/分区/逻辑驱动器。所以通常建议的 GetVolumeInformation
函数不适用于我的情况。
I'm talking about the physical disk drive, not volume/partition/logical drive. So that usually-suggested GetVolumeInformation
function is not applicable in my case.
确切地说:直接与尚未被分区的盘。
我通过 CreateFile
函数打开一个句柄:
To be exact: I'm working directly with the disk which has not been partitioned yet.I open a handle to it via CreateFile
function:
hDisk = CreateFile(
_T("\\\\.\\PHYSICALDRIVE0"),
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED|FILE_FLAG_NO_BUFFERING,
NULL);
我可以使用此句柄直接在磁盘上读/写。还可以使用 DeviceIoControl
函数查询各种磁盘属性。但是我找不到一种方法来查询在设备管理器中可见的磁盘供应商/序列属性。
I can read/write directly on the disk using this handle. There's also a possibility to query various disk properties using DeviceIoControl
function. However I couldn't find a way to query the disk vendor/serial properties, which are visible in the device manager.
推荐答案
请查看。源代码也有。建议使用 DFP_RECEIVE_DRIVE_DATA
与 DeviceIoControl
。
Take a look at DiskId32. Source code is there also. The idea is to use DFP_RECEIVE_DRIVE_DATA
with DeviceIoControl
.
这篇关于如何使用Windows API检索HD供应商/序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!