Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
564 views
in Technique[技术] by (71.8m points)

c# - Monitor a process's network usage?

Is there a way in C# or C/C++ & Win32 to monitor a certain process's network usage (Without that application being built by you obviously)? I would like to monitor just 1 process for like an hour or so, then return the bytes used by only that process, such as limewire for example.

Is it possible? I know netstat -e on windows will tell you total bytes sent/received, but that is for all processes.

edit: If i can't return just one processes usage, how can i get the bytes sent/received by the entire system? as netstat displays except i just want the integers.

eg:

netstat -e

                           Received            Sent

Bytes                    2111568926      1133174989
Unicast packets             3016480         2711006
Non-unicast packets            3122            1100
Discards                          0               0
Errors                            0               0
Unknown protocols                 0

I just want to get 2 variables, like rec = 2111568926 and sent = 1133174989

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could use WinPcap for this or write your own device driver. I don't think there are any per process perfmon counters you can leverage.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...