百度首页 | 百度空间
 
查看文章
 
C# 判断计算机网络是否可用
2007-12-12 11:21

首先添加引用:

using System.Runtime.InteropServices;

代码:

[DllImport("wininet.dll")]

private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);

private static bool IsConnected()

{

    int I = 0;

    bool state = InternetGetConnectedState(out I, 0);

    return state;

}

使用方法:

textBox1.Text = IsConnected().ToString();

这样就可以返回一个Bool值,表示目前网络的状态。


类别:c# 技术 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu