gpt4 book ai didi

c# - 每个应用程序中的互联网使用情况

转载 作者:太空狗 更新时间:2023-10-30 01:26:24 25 4
gpt4 key购买 nike

我想问一下如何获得流媒体等应用程序正在使用的互联网数量。我想用 C# 制作一个程序,但我不知道如何启动它....给点建议谢谢

最佳答案

作为起点,我会查看 WinSock应用程序接口(interface)。您可能会找到一种基于每个进程提取流量信息的方法。如果您想查看总网络使用情况,我会使用性能监控工具。我从 web search 中找到了这个例子:

private static void ShowNetworkTraffic()
{
PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface");
string instance = performanceCounterCategory.GetInstanceNames()[0]; // 1st NIC !
PerformanceCounter performanceCounterSent = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instance);
PerformanceCounter performanceCounterReceived = new PerformanceCounter("Network Interface", "Bytes Received/sec", instance);

for (int i = 0; i < 10; i++)
{
Console.WriteLine("bytes sent: {0}k\tbytes received: {1}k", performanceCounterSent.NextValue() / 1024, performanceCounterReceived.NextValue() / 1024);
Thread.Sleep(500);
}
}

关于c# - 每个应用程序中的互联网使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4992746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com