using System.Runtime.InteropServices;
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ; private void button2_Click(object sender, EventArgs e)
{
if (IsConnected())
{
MessageBox.Show("tong!");
} }
private bool IsConnected()
{
int I = 0;
bool state = InternetGetConnectedState(out I, 0);
return state;
}网上找的原代码用的,但是 在编辑运行的时候发现,无论我断网了 还是没断网都显示 :未断网是我哪里没注意到吗?谢谢!
解决方案 »
- Microsoft.Win32.TaskScheduler
- usb wirtefile失敗
- vs2005多类库引用的问题
- c# textbox 只能 输入数字,退格,小数点。如何实现
- 如何使用sqlhelper;跪谢
- 如何把C#的多個cs文件和rpx文件一齊編譯成.dll文件
- 根据内容改变datagrid里单元格的颜色?
- datagrid用什么方法选择数据行
- 如何封装一个Soap消息包,为什么没有SoapFormatter???
- 请问:如何实现控件中程序中的拖放??
- specified argument was out of the range of vaild values
- Extjs gridPanel导出Excel 如何实现?(WebForm)
Ping测试网络连通性实现代码
http://www.csharphelp.com/archives2/files/archive296/ping.cs我答复的帖子:http://topic.csdn.net/u/20100619/14/74557951-0f81-49c2-9440-a72ada178b60.html