c#判斷是否有網絡

//調用操做系統API  
[System.Runtime.InteropServices.DllImport("wininet")]
private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
      

/// <summary>
        /// 判斷是否連接到外網
        /// </summary>
        public static bool IsNetWorkConnect()
        {
            int i = 0;
            return InternetGetConnectedState(out i, 0) ? true : false;
        }
相關文章
相關標籤/搜索