Go to my github

C# 检查网络是否连通

        [DllImport("wininet.dll")]
        
private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
        
private bool IsConnected()
        {

            
int I = 0;

            
bool state = InternetGetConnectedState(out I, 0);

            
return state;

        }

调用方法:

 

bool state = IsConnected();   //True 为连通   False 为断开

 

posted @ 2010-03-03 23:12  峡谷少爷  阅读(588)  评论(0编辑  收藏  举报