posted by 방랑군 2012. 1. 7. 21:01

출처 :  http://blog.naver.com/PostView.nhn?blogId=inidu2&logNo=110032861546&categoryNo=0&parentCategoryNo=33&viewDate=&currentPage=4&postListTopCurrentPage=1&userTopListOpen=true&userTopListCount=10&userTopListManageOpen=false&userTopListCurrentPage=4


인터넷이 연결이 되었는지를 체크하기위한 코드..

마이크로 소프트의 SmartClient Application Building Block 중에서 온라인 체크및 각종 기능이 있다는데.. 
간단히 코드로 확인하는방법이 ..

 

출처 : http://www.c-sharpcorner.com/Code/2003/Aug/CheckInternetConnection.asp

 

using System ;
using
 System.Runtime ;
using System.Runtime.InteropServices ;
 

public class InternetCS
{

//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int Description, intReservedValue ) ;

//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{

int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;

}

}

 
 
인터넷이 끊어지는 상황이 발생 중간중간 연결 여부를 체크할 필요가 있어졌다.
연결이 되어 있을때만 실행.