判断网络连接是否通

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Runtime.InteropServices;

public partial class Hy_De : System.Web.UI.Page
{
    [DllImport("wininet.dll")]
    private extern static bool InternetGetConnectedState(out int conn, int val);
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        int Out;
        if (InternetGetConnectedState(out Out, 0) == true)
        {
            Response.Write("通!");
        }
        else
        {
            Response.Write("不通!");
        }

    }
}

posted @ 2012-02-08 10:07  你妹的sb  阅读(236)  评论(1编辑  收藏  举报
百度一下