雨田博客
让斗志、坚持、自信成为习惯

导航

 
public static class Internet
    {
        [DllImport("winInet.dll")]
        private static extern bool InternetGetConnectedState(ref int dwFlag, int dwReserved);
     
        /// <summary>
        /// 返回网络状态
        /// </summary>
        public static bool Status
        {
            get
            {
                Int32 dwFlag = new int();
                if (!InternetGetConnectedState(ref dwFlag, 0))
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }
    }

  

posted on 2016-03-10 14:31  张雨田  阅读(1471)  评论(0编辑  收藏  举报