Search code examples
performancewinapidiskdiagnostics

Disk Write Queue Length


In the win32 API how can I access the average write queue length for the drive of a specific path?

I've tried looking a for a psapi function without success...

I found something about a "physical disk object" but nothing about how the get it.


Solution

  • It is device driver detail. Whenever you go hunting for such details there are three places you look:

    • An IOCTL, the kind you use with DeviceIoControl(). That is a dead end.
    • A performance counter, Perfmon.exe is the best tool to see what is available. Out pops category "LogicalDisk", counter "Current Disk Queue Length", instance is the drive letter
    • A WMI query, best googled with a query like "wmi disk queue length". Out pops the first hit, the Win32_PerfFormattedData_PerfDisk_PhysicalDisk class.

    Lots of sample code around to show you how to use a performance counter or a WMI query in your code, google away.