Windows 的哪些版本实施了存储管理 API 类,例如 'MSFT_PhysicalDisk'?

In what versions of Windows are Storage Management API Classes such as 'MSFT_PhysicalDisk' implemented?

我正在尝试从 MSFT_PhysicalDisk 中提取 'MediaType' 等指标。我在 Windows 10 机器上成功,但在 Windows 7 机器上失败。

MSFT_PhysicalDisk 在什么类型的机器上可用?

存储管理参考API类: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/storage-management-api-classes

请参阅下面的代码,了解我正在尝试做的事情的示例:

bool isSsd;
try
{
    var physDiskQuery =
        $"SELECT MediaType FROM MSFT_PhysicalDisk WHERE DeviceID='{driveNumber.Value}'";

    var wmiScope = @"\.\root\microsoft\windows\storage";
    using (var physicalDiskSearcher = new ManagementObjectSearcher(wmiScope, physDiskQuery))
    {
        var objectCollection = physicalDiskSearcher.Get();
        var physicalDisk = objectCollection.Cast<ManagementBaseObject>().SingleOrDefault();
        if (physicalDisk == null)
            return null;

        isSsd = (ushort)physicalDisk["MediaType"] == 4;
    }
}
catch (Exception exception)
{
    Debug.WriteLine($"Error while checking for SSD drive. Details: {exception.GetBaseException()}");
    return null;
}

return isSsd;

MSDN 文档在页面底部列出了要求 way。对于 MSFT_PhysicalDisk class 它说...

Minimum supported client: Windows 8 [desktop apps only]

Minimum supported server: Windows Server 2012 [desktop apps only]

换句话说,你至少需要 Windows version 6.2.