using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;

namespace SmsSoft
{
    public class CheckInternetConnection
    {
        /// <summary>
        /// 用于检查网络是否可以连接互联网,true表示连接成功,false表示连接失败
        /// </summary>
        /// <returns></returns>
        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState(int Description, int ReservedValue);
        public static bool CheckConnection()
        {       
            int Description = 0;
            return InternetGetConnectedState(Description, 0);
        }

    }
}

 

原文地址:http://blog.csdn.net/vince6799/archive/2010/09/10/5876051.aspx

posted on 2010-09-11 09:58  Hong.S  阅读(215)  评论(0编辑  收藏  举报