vpn是否连接上,用VB如何判断?

解决方案 »

  1.   

    Private Function InternetConnected(Optional ByRef eConnectionInfo _
        As EIGCInternetConnectionState, Optional ByRef _
        sConnectionName As String) As Boolean                  '判断是否连接到internet子程序
        
        Dim dwFlags As Long
        Dim sNameBuf As String
        Dim lR As Long
        Dim iPos As Long
        
        sNameBuf = String$(513, 0)
        lR = InternetGetConnectedStateEx(dwFlags, sNameBuf, 512, 0&)
        eConnectionInfo = dwFlags
        iPos = InStr(sNameBuf, vbNullChar)
        If iPos > 0 Then
            sConnectionName = Left$(sNameBuf, iPos - 1)
        ElseIf Not sNameBuf = String$(513, 0) Then
            sConnectionName = sNameBuf
        End If
        InternetConnected = (lR = 1)
    End Function
      

  2.   

    不知道能不能判断VPN,你试试看啦