Programmatically getting per-process disk io statistics on Windows?

戏子无情 提交于 2019-12-17 18:46:10

问题


I would like to display a list of processes (Windows, C++) and how much they are reading and writing from the disk in KB/sec.

The Resource Monitor of Windows 7 has the ability so I should be able to do the same.

However I have unable to find a relevant API-call or find anything in the perfmon counters. Could anyone point me in the direction?


回答1:


You can call GetProcessIoCounters to get overall disk I/O data per process - you'll need to keep track of deltas and converting to time-based rate yourself.

This API will tell you total number of I/O operations as well as total bytes.




回答2:


WMI can do it, as long as you periodically snapshot it to get differential stats for some "recent" slice of time. This post presents a peculiarly mixed solution, with VBScript reading the info from WMI and Perl continually presenting the information in a Windows console. Despite the strange language mix, I think it stands as a good example of how to get at the kind of information you require (it should be quite possible to recode all of it in C++, of course).



来源:https://stackoverflow.com/questions/1639903/programmatically-getting-per-process-disk-io-statistics-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!