Results 1 to 6 of 6

Thread: Internet Connection

  1. #1
    Guest

    Talking

    How do I check if a user is connected to the internet and how do I get the name of the connection if he is?

    BTW, I tried the various RAS APIs but they only work with dialups.

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Post Hi Sc0rp,

    Check out this previous thread from this site:

    http://forums.vb-world.net/showthrea...threadid=10198

    Also, I think there's a tutorial on this site that deals with the same topic. Snoop around for it.

    All the best.


  3. #3
    Guest

    Unhappy Problem

    There's a problem with this code

    Code:
    Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long
    
    Public Function IsOnline() As Boolean
        'If you are online it will return True, otherwise False
        IsOnline = InternetGetConnectedState(0&, 0&)
    End Function
    If I'm connected then it returns - true.
    If I'm NOT connected it also returns - true.

    Any ideas?

    BTW, is it true that 'wininet.dll' comes with IE4?

  4. #4
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    there is a problem in a module, try this:
    Code:
    'in a button
    Text1 = ViaLAN()
    Text2 = ViaModem()
    Text3 = Online()
    If Text3.Text = "True" Then MsgBox "You are online"
    If Text3.Text = "False" Then MsgBox "You are not online"
    
    'in Declarations
    Private Sub HowConnected_Click()
    Text1 = ViaLAN()
    Text2 = ViaModem()
    Text3 = Online()
    If Text2.Text = "True" Then MsgBox "You are connected with a modem"
    If Text1.Text = "True" Then MsgBox "You are connected with a LAN"
    If Text3.Text = "False" Then MsgBox "You aren't online!"
    End Sub
    
    
    
    'in a module
    Option Explicit
    Public Declare Function InternetGetConnectedState _
    Lib "wininet.dll" (ByRef lpSFlags As Long, _
    ByVal dwReserved As Long) As Long
    
    Public Const INTERNET_CONNECTION_LAN As Long = &H2
    Public Const INTERNET_CONNECTION_MODEM As Long = &H1
    
    
    Public Function Online() As Boolean
        'If you are online it will return True, otherwise False
        Online = InternetGetConnectedState(0&, 0&)
    End Function
    
    Public Function ViaLAN() As Boolean
    
    Dim SFlags As Long
    'return the flags associated with the connection
    Call InternetGetConnectedState(SFlags, 0&)
    
    'True if the Sflags has a LAN connection
    ViaLAN = SFlags And INTERNET_CONNECTION_LAN
    
    End Function
    Public Function ViaModem() As Boolean
    
    Dim SFlags As Long
    'return the flags associated with the connection
    Call InternetGetConnectedState(SFlags, 0&)
    
    'True if the Sflags has a modem connection
    ViaModem = SFlags And INTERNET_CONNECTION_MODEM
    
    End Function

  5. #5
    Guest
    That doesn't work as well

  6. #6
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    It works for me in my program...email me, I'll send it to you
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width