我想获取物理磁盘的缓存、转速(仅限机械磁盘),物理磁盘的性能指标:IO延迟、读IO/s、写IO/s、读KB/s、写KB/s、读error/s、写error/s,逻辑磁盘的inode可用、inode使用率的消息(物理磁盘是硬盘,逻辑磁盘是C,D,E,F卷这种)
代码实现:
#include <iostream>
#include <windows.h>
#include <winioctl.h>
#define SECTOR_SIZE 512
// 获取物理磁盘信息
void GetPhysicalDiskInfo()
{
std::cout << "Physical Disk Info:" << std::endl;
DWORD drives = GetLogicalDrives();
char driveLetter = 'A';
while (drives)
{
if (drives & 1)
{
char drivePath[7];
sprintf_s(drivePath, "\\\\.\\%c:", driveLetter);
// 获取磁盘句柄
HANDLE hDevice = CreateFileA(