请问如何用程序实现:判断一台计算机是否正在上网?
    我考虑是判断其DNS是否可以PING通!但是不知道VB下其的代码如何编写!
希望能得到这样的例子!
谢谢!

解决方案 »

  1.   

    Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, ByVal dwNameLen As Integer, ByVal dwReserved As Long) As LongPublic Function CheckInternetConnection() As Boolean
        Dim aux As String * 255
        Dim r As Long
        r = InternetGetConnectedStateEx(r, aux, 254, 0)
        If r = 1 Then
            CheckInternetConnection = True
        Else
            CheckInternetConnection = False
        End If
    End Function' Usage:
    ...
    If (CheckInternetConnection = True)
        MsgBox "We have an active Internet connection!"
    Else
        MsgBox "We don't have an active Internet connection!"
    End If
    ...