VB.NET 检查 网络连接

Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Integer, ByVal dwReserved As Integer) As Integer
 Public Shared Function IfOnline() As Boolean
            Const FLAG_ICC_FORCE_CONNECTION As Integer = &H1
            Return InternetCheckConnection("http://www.baidu.com", FLAG_ICC_FORCE_CONNECTION, 0)
        End Function

if IfOnline() =True then

msgbox("网络通畅")

else

msgbox("网络不通畅")

end if

猜你喜欢

转载自blog.csdn.net/polloo2012/article/details/82917883
今日推荐