How to obtain the value of unallocated space of each hard disk of the computer through the Windows interface?

凯 于 1 Reputation point
2022-10-28T03:24:38.587+00:00

Now I want to read the value of the unallocated space of each hard disk of the computer through the Windows interface, as shown in the red box in the figure. I tried using WMI, but it doesn't seem like there's any good way to do it right now. (If there is a relevant interface, expect to call it via Python or C#)
Thanks~254906-73bd8637-46af-4864-92b4-fb56b57359dd.png

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,468 questions
Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,567 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 82,241 Reputation points
    2022-10-28T13:31:29.613+00:00

    It can be done by enumerating volumes (IVdsPack::QueryVolumes) and subtracting the volumes sizes (IVdsVolume::GetProperties)
    from disk size IVdsDisk::GetProperties
    But it is complex (tested on Windows 10 21H1)

    1 person found this answer helpful.
    0 comments No comments

  2. Xiaopo Yang - MSFT 11,746 Reputation points Microsoft Vendor
    2022-10-31T02:46:56.01+00:00
    1 person found this answer helpful.
    0 comments No comments