怎样判断计算机是否连接互联网

解决方案 »

  1.   

    一般方法:
    发一段信息到某著名网站,若有反应,则说明在网上。
    具体实现:
    先引用Microsoft Internet Transfer 控件
    名为Inet1
        Dim strT As String
        strT = Me.Inet1.OpenURL("www.sina.com")
        If strT = "" Then
            MsgBox "no"
        Else
            MsgBox "ok"
        End If
      

  2.   

    检查连接状况:
    Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
    Public Function IsConnected() As Boolean
        If InternetGetConnectedState(0&, 0&) = 1 Then
            IsConnected = True
        Else
            IsConnected = False
        End If
    End Function
      

  3.   

    同意hengxin54(火星) 
    不过要ie4。0以上
      

  4.   

    不行啊
    不管上不上網都是True
      

  5.   

    你连局于网了吧。连了也是true。要读注册表判断
      

  6.   

    想知道自已是否在线的又一好方法  执行   ping -n 1 www.zz.ha.cn >c:\1.txt如果PING正常,说明连接中.