代码改变世界

用C#检测你的网络连接(转载)

2010-03-02 20:31  爱研究源码的javaer  阅读(337)  评论(0编辑  收藏  举报

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

public class InternetCS
{

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

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

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

}

}

转自:http://blog.csdn.net/rcom10002/archive/2005/01/11/249267.aspx