检测网络状态(连接 - 断开连接)在C# [英] Detecting network state (connected - disconnected) in C#

查看:1702
本文介绍了检测网络状态(连接 - 断开连接)在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一段代码如果网络连接被连接或断开,可以检测的。连接状态将意味着电缆被插入以太网连接。断开状态将意味着没有连接的电缆。

I am in need of a piece of code that can detect if a network connection is connected or disconnected. The connected state would mean a cable was plugged into the Ethernet connection. A disconnected state would mean there is not cable connected.

我不能使用WMI接口由于我正在运行在Windows CE的事实。我不介意调用Win32 API的,但请记住,我使用Windows CE和Compact Framework的运行。

I can't use the WMI interface due to the fact that I'm running on Windows CE. I don't mind invoking the Win32 API but remember that I'm using Windows CE and running on the Compact Framework.

推荐答案

看看这个MSDN文章:

Check out this MSDN article:

测试和响应在.NET Compact Framework的

这篇关于检测网络状态(连接 - 断开连接)在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆