title: Programmatically getting per-process network statistics on Windows?
body: <p>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.</p>
  
  <p>Essentially, I'd like, for each process, to know how many bytes it has read/written to the network over a time period. If I could know IP addresses/port numbers, etc., that would be awesome.</p>
  
  <p>Any pointers? Windows Vista/Windows 2008 seem to be able to do this in Resource Monitor. How do they do it? What's the overhead?</p>
  
  <p>I want to do this in my own code, so utilities (TCPView, PerfMon) aren't useful to me. I'd also like to have separate disk and network I/O counters, so the default performance counters aren't enough.</p>
  
  <p>Windows XP, 2003, Vista, 2008 and 7 preferred. Win32 or COM OK.</p>