如何获取网络设备的在线时长?
我希望我的c#程序能够显示网络设备的在线时长。我已经尝试过 NetworkInterface 类,但它没有该信息。
i want my c# program to be able to display the online duration of the network device. i have tried NetworkInterface
class but it does not have that info.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用 DotRas (http://dotras.codeplex.com/),如网站上所述,“为 C#、VB.NET 和 C++ CLR 项目等 .NET 语言提供远程访问服务 (RAS) 组件”。
通过检查函数 RasGetConnectionStatistics (MSDN 文档)我发现它返回其中包含字段“dwConnectDuration”的结构 (RAS_STATS)。
希望 DotRas 将为您提供一种在 C# 中访问该函数及其返回的所有数据的简单方法。
参考文献:
http://bytes.com/topic/net /answers/484607-字节发送接收网络适配器
http://channel9.msdn.com/ forums/TechOff/69065-使用-C 创建-RAS-连接/
Try getting it through RAS (Remote Access Service), by using DotRas (http://dotras.codeplex.com/), that "Provides remote access service (RAS) components for .NET languages like C#, VB.NET, and C++ CLR projects" as stated on the website.
By checking the function RasGetConnectionStatistics (MSDN documentation) I've found it returns a structure (RAS_STATS) that has the field "dwConnectDuration" in it.
Hopefully DotRas will provide you a easy way to access that function in C#, along with all the data it returns.
References:
http://bytes.com/topic/net/answers/484607-bytes-sent-received-network-adapter
http://channel9.msdn.com/forums/TechOff/69065-Creating-a-RAS-connection-with-C/
首先,你必须找到这个网络接口设备。您可以使用GetAllNetworkInterfaces()来完成此操作。现在,您已经有了一个网络接口。之后,网络接口发送此方法。
您还可以检查 这个例子。
First of all, you must find this network interface device. You can do this by using the GetAllNetworkInterfaces().Now, you have a network interface. After, the network interface send this methot.
You can also examine this example.
首先添加来自 Network List Manager 1.0 类型库的引用。在这里您可以根据时区更改日期
First Add reference from Network List Manager 1.0 Type Library. Here you can change date as per timezone