프로그래밍/C#

[C#] 인터넷 연결 유무 확인

암리타 2012. 3. 28. 14:55
    class Internet
    {
        //Creating the extern function...
        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState( out int Description, 
                  int ReservedValue ) ;

        /// <summary>
        /// 인터넷 연결 체크
        /// </summary>
        /// <returns>인터넷 연결이 안된 경우 false</returns>
        public static bool IsConnectedToInternet( )
        {
            int Desc ;
            return InternetGetConnectedState( out Desc, 0 ) ;
        }
    }