Programmatically getting per-process network statistics on Windows?

前端 未结 5 1240
天命终不由人
天命终不由人 2020-12-14 11:21

I\'d like to find out which processes are using my network. This is quite easy in Linux, but I\'m stumped as to how to do this in Windows.

Essentially, I\'d like, fo

5条回答
  •  無奈伤痛
    2020-12-14 11:57

    You'd be amazed at the stuff you can get out of Perfmon.

    Bring it up, right click in the graph area, and select "Add Counters...". Surf around and see if anything does what you want.

    From my reading of what you are asking, I'd select "Process" as my performance object, and start selecting likely looking culprits from the list of processes, with perhaps "IO Data Bytes/sec" counters being watched. If you mess around in there you may find something more useful to you to look at though.

    Edit: I'm noticing that it says "Programatically" (did it say that yesterday?)

    Well, you can actually get pretty much all the information Perfmon gets from the registry with the key HKEY_PERFORMANCE_DATA. I think that's what Perfmon enumerates and uses, so you should be able to poke around with perfmon to see what's there and works for you, then write code to read it out in realtime in your own program.

    One of the really nice things about this method, is that it even works remotely, if you have the right privs.

提交回复
热议问题